errose28 commented on code in PR #359: URL: https://github.com/apache/ozone-site/pull/359#discussion_r2891387370
########## eslint.config.mjs: ########## @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import js from "@eslint/js"; +import globals from "globals"; +import pluginReact from "eslint-plugin-react"; +import css from "@eslint/css"; +import { defineConfig } from "eslint/config"; +import pluginDocusaurus from "@docusaurus/eslint-plugin"; +import pluginUnusedImports from "eslint-plugin-unused-imports"; +import pluginImport from "eslint-plugin-import"; + +const apacheLicenseRule = { + meta: { + type: "problem", + docs: { + description: "Enforce Apache License header in source files", + }, + fixable: "code", + messages: { + missingHeader: "Missing Apache License header at the top of the file", + }, + }, + create(context) { + const REQUIRED_HEADER = `/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */`; + + return { + Program(node) { + const sourceCode = context.sourceCode || context.getSourceCode(); + const text = sourceCode.getText(); + + if (!text.startsWith(REQUIRED_HEADER)) { + context.report({ + node, + messageId: "missingHeader", + fix(fixer) { + return fixer.insertTextBefore(node, REQUIRED_HEADER + "\n\n"); + }, + }); + } + }, + }; + }, +}; + +export default defineConfig([ + // General + { + ignores: [ + "static/**", + "node_modules/**", + "build/**", + "dist/**", + ".docusaurus/**", + ".github/**", + ], + }, + + // JS + { + files: ["**/*.{js,mjs,cjs,jsx}"], + ...js.configs.recommended, + languageOptions: { globals: { ...globals.browser, ...globals.node } }, + plugins: { + "unused-imports": pluginUnusedImports, + import: pluginImport, + }, + rules: { + "unused-imports/no-unused-imports": "error", + // unused vars (but ignore underscore-prefixed) + "unused-imports/no-unused-vars": [ + "warn", + { + vars: "all", + varsIgnorePattern: "^_", + args: "after-used", + argsIgnorePattern: "^_", + }, + ], + "import/no-duplicates": "error", + "no-unused-vars": "off", + }, + }, + + // React + { + files: ["**/*.{js,jsx}"], + ...pluginReact.configs.flat.recommended, + settings: { + react: { version: "detect" }, + }, + rules: { + "react/prop-types": "off", + "react/react-in-jsx-scope": "off", + "react/jsx-uses-vars": "error", + }, + }, + + // CSS + { + files: ["**/*.css"], + plugins: { css }, + language: "css/css", + extends: ["css/recommended"], + rules: { + "css/no-invalid-properties": "off", + "css/no-important": "off", + "css/use-baseline": "off", + }, + }, + + // Docusaurus + { + files: ["**/*.{js,mjs,cjs,jsx}"], + plugins: { "@docusaurus": pluginDocusaurus }, + rules: { + "@docusaurus/no-html-links": "error", + "@docusaurus/prefer-docusaurus-heading": "error", + "@docusaurus/string-literal-i18n-messages": "error", + // for i18n + // "@docusaurus/no-untranslated-text": ["warn", { ignoredStrings: [] }] + }, + }, + + // Custom rule to enforce Apache License header + { + files: ["**/*.{js,mjs,cjs,jsx}"], Review Comment: I don't think we need this. We already have a license header check using skywalking-eyes for all files in CI which is more robust than this strict string constant header check. This does run locally on `pnpm lint` which is nice, but it only checks javascript files which are rarely modified. I don't think we would want to expand the scope to other file types since it's more brittle than skywalking eyes anyways. I think we can remove this to keep our linting config simple and reduce duplication/conflicts with skywalking-eyes. In a follow-up change it would be good to have skywalking-eyes run locally on lint too, but that would also require a separate [install](https://github.com/apache/skywalking-eyes?tab=readme-ov-file#docker-image) outside of node.js. ########## eslint.config.mjs: ########## @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import js from "@eslint/js"; +import globals from "globals"; +import pluginReact from "eslint-plugin-react"; +import css from "@eslint/css"; +import { defineConfig } from "eslint/config"; +import pluginDocusaurus from "@docusaurus/eslint-plugin"; +import pluginUnusedImports from "eslint-plugin-unused-imports"; +import pluginImport from "eslint-plugin-import"; + +const apacheLicenseRule = { + meta: { + type: "problem", + docs: { + description: "Enforce Apache License header in source files", + }, + fixable: "code", + messages: { + missingHeader: "Missing Apache License header at the top of the file", + }, + }, + create(context) { + const REQUIRED_HEADER = `/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */`; + + return { + Program(node) { + const sourceCode = context.sourceCode || context.getSourceCode(); + const text = sourceCode.getText(); + + if (!text.startsWith(REQUIRED_HEADER)) { + context.report({ + node, + messageId: "missingHeader", + fix(fixer) { + return fixer.insertTextBefore(node, REQUIRED_HEADER + "\n\n"); + }, + }); + } + }, + }; + }, +}; + +export default defineConfig([ + // General + { + ignores: [ + "static/**", + "node_modules/**", + "build/**", + "dist/**", + ".docusaurus/**", + ".github/**", + ], + }, + + // JS + { + files: ["**/*.{js,mjs,cjs,jsx}"], + ...js.configs.recommended, + languageOptions: { globals: { ...globals.browser, ...globals.node } }, + plugins: { + "unused-imports": pluginUnusedImports, + import: pluginImport, + }, + rules: { Review Comment: Do we want to add a rule to enforce import order? ########## eslint.config.mjs: ########## @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import js from "@eslint/js"; +import globals from "globals"; +import pluginReact from "eslint-plugin-react"; +import css from "@eslint/css"; +import { defineConfig } from "eslint/config"; +import pluginDocusaurus from "@docusaurus/eslint-plugin"; +import pluginUnusedImports from "eslint-plugin-unused-imports"; +import pluginImport from "eslint-plugin-import"; + +const apacheLicenseRule = { + meta: { + type: "problem", + docs: { + description: "Enforce Apache License header in source files", + }, + fixable: "code", + messages: { + missingHeader: "Missing Apache License header at the top of the file", + }, + }, + create(context) { + const REQUIRED_HEADER = `/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */`; + + return { + Program(node) { + const sourceCode = context.sourceCode || context.getSourceCode(); + const text = sourceCode.getText(); + + if (!text.startsWith(REQUIRED_HEADER)) { + context.report({ + node, + messageId: "missingHeader", + fix(fixer) { + return fixer.insertTextBefore(node, REQUIRED_HEADER + "\n\n"); + }, + }); + } + }, + }; + }, +}; + +export default defineConfig([ + // General + { + ignores: [ + "static/**", + "node_modules/**", + "build/**", + "dist/**", + ".docusaurus/**", + ".github/**", + ], + }, + + // JS + { + files: ["**/*.{js,mjs,cjs,jsx}"], + ...js.configs.recommended, + languageOptions: { globals: { ...globals.browser, ...globals.node } }, + plugins: { + "unused-imports": pluginUnusedImports, + import: pluginImport, + }, + rules: { + "unused-imports/no-unused-imports": "error", + // unused vars (but ignore underscore-prefixed) + "unused-imports/no-unused-vars": [ + "warn", Review Comment: I don't think warning are useful, people will only check if the command passes or fails. If we care about something we should make it an error. Unused variables should fail linting I think. ########## package.json: ########## @@ -13,8 +13,8 @@ "serve": "docusaurus serve --port 3001", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "lint": "markdownlint \"$(git rev-parse --show-toplevel)\" && yamllint --format=colored \"$(git rev-parse --show-toplevel)\"", - "lint:fix": "markdownlint --fix \"$(git rev-parse --show-toplevel)\" && yamllint --format=colored \"$(git rev-parse --show-toplevel)\"" + "lint": "eslint . && markdownlint \"$(git rev-parse --show-toplevel)\" && yamllint --format=colored \"$(git rev-parse --show-toplevel)\"", + "lint:fix": "eslint --fix . && markdownlint --fix \"$(git rev-parse --show-toplevel)\" && yamllint --format=colored \"$(git rev-parse --show-toplevel)\"" Review Comment: After some testing, it looks like the `.` is always resolved to the repo root regardless of which tool is used. Also switching `&&` for `;` lets us run all linters at once instead of stopping when the first one hits an error. ```suggestion "lint": "eslint . ; markdownlint . ; yamllint --format=colored .", "lint:fix": "eslint --fix . ; markdownlint --fix . ; yamllint --format=colored ." ``` To test this I added this diff and ran `pnpm lint` from the `docs` directory, which is lower in the directory tree than any of these changes. Linting errors on all three files were correctly flagged. ```diff diff --git a/compose.yml b/compose.yml index 1a6c84659..32e67770b 100644 --- a/compose.yml +++ b/compose.yml @@ -17,7 +17,7 @@ version: "3" services: site: - build: . + build: . image: ozone-site ports: - 3001:3001 diff --git a/package.json b/package.json index 4277cbaf5..e0739a14b 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "serve": "docusaurus serve --port 3001", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "lint": "eslint . && markdownlint \"$(git rev-parse --show-toplevel)\" && yamllint --format=colored \"$(git rev-parse --show-toplevel)\"", - "lint:fix": "eslint --fix . && markdownlint --fix \"$(git rev-parse --show-toplevel)\" && yamllint --format=colored \"$(git rev-parse --show-toplevel)\"" + "lint": "eslint . ; markdownlint . ; yamllint --format=colored .", + "lint:fix": "eslint --fix . ; markdownlint --fix . ; yamllint --format=colored ." }, "dependencies": { "@docusaurus/core": "3.7.0", diff --git a/src/pages/download.md b/src/pages/download.md index 2fefd7658..c543ef39e 100644 --- a/src/pages/download.md +++ b/src/pages/download.md @@ -6,7 +6,7 @@ | 2.0.0 | 2025 Apr 30 | [Source](https://www.apache.org/dyn/closer.cgi/ozone/2.0.0/ozone-2.0.0-src.tar.gz)<br/>[Checksum](https://downloads.apache.org/ozone/2.0.0/ozone-2.0.0-src.tar.gz.sha512)<br/>[Signature](https://downloads.apache.org/ozone/2.0.0/ozone-2.0.0-src.tar.gz.asc) | [Binary](https://www.apache.org/dyn/closer.cgi/ozone/2.0.0/ozone-2.0.0.tar.gz)<br/>[Checksum](https://downloads.apache.org/ozone/2.0.0/ozone-2.0.0.tar.gz.sha512)<br/>[Signature](https://downloads.apache.org/ozone/2.0.0/ozone-2.0.0.tar.gz.asc) | [Release Notes](/release-notes/2.0.0) | | 1.4.1 | 2024 Nov 24 | [Source](https://www.apache.org/dyn/closer.cgi/ozone/1.4.1/ozone-1.4.1-src.tar.gz)<br/>[Checksum](https://downloads.apache.org/ozone/1.4.1/ozone-1.4.1-src.tar.gz.sha512)<br/>[Signature](https://downloads.apache.org/ozone/1.4.1/ozone-1.4.1-src.tar.gz.asc) | [Binary](https://www.apache.org/dyn/closer.cgi/ozone/1.4.1/ozone-1.4.1.tar.gz)<br/>[Checksum](https://downloads.apache.org/ozone/1.4.1/ozone-1.4.1.tar.gz.sha512)<br/>[Signature](https://downloads.apache.org/ozone/1.4.1/ozone-1.4.1.tar.gz.asc) | [Release Notes](/release-notes/1.4.1) | -## Archives +### Archives Older releases are available from the [Apache Ozone archive](https://archive.apache.org/dist/ozone/). diff --git a/src/theme/DocSidebar/index.module.css b/src/theme/DocSidebar/index.module.css index 39601f08f..c3d7447af 100644 --- a/src/theme/DocSidebar/index.module.css +++ b/src/theme/DocSidebar/index.module.css @@ -48,6 +48,6 @@ aside .customSidebarInner { aside .customSidebarVersion p { margin-bottom: 0; - font-size: var(--fbc-font-size, 13px); + font-size: var(--fbc-font-size: 13px;); padding: var(--ifm-menu-link-padding-vertical) var(--ifm-menu-link-padding-horizontal); } ``` ########## eslint.config.mjs: ########## @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import js from "@eslint/js"; +import globals from "globals"; +import pluginReact from "eslint-plugin-react"; +import css from "@eslint/css"; +import { defineConfig } from "eslint/config"; +import pluginDocusaurus from "@docusaurus/eslint-plugin"; +import pluginUnusedImports from "eslint-plugin-unused-imports"; +import pluginImport from "eslint-plugin-import"; + +const apacheLicenseRule = { + meta: { + type: "problem", + docs: { + description: "Enforce Apache License header in source files", + }, + fixable: "code", + messages: { + missingHeader: "Missing Apache License header at the top of the file", + }, + }, + create(context) { + const REQUIRED_HEADER = `/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */`; + + return { + Program(node) { + const sourceCode = context.sourceCode || context.getSourceCode(); + const text = sourceCode.getText(); + + if (!text.startsWith(REQUIRED_HEADER)) { + context.report({ + node, + messageId: "missingHeader", + fix(fixer) { + return fixer.insertTextBefore(node, REQUIRED_HEADER + "\n\n"); + }, + }); + } + }, + }; + }, +}; + +export default defineConfig([ + // General + { + ignores: [ + "static/**", + "node_modules/**", + "build/**", + "dist/**", Review Comment: I don't see a dist directory in the repo. Does something generate this? ########## eslint.config.mjs: ########## @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import js from "@eslint/js"; +import globals from "globals"; +import pluginReact from "eslint-plugin-react"; +import css from "@eslint/css"; +import { defineConfig } from "eslint/config"; +import pluginDocusaurus from "@docusaurus/eslint-plugin"; +import pluginUnusedImports from "eslint-plugin-unused-imports"; +import pluginImport from "eslint-plugin-import"; + +const apacheLicenseRule = { + meta: { + type: "problem", + docs: { + description: "Enforce Apache License header in source files", + }, + fixable: "code", + messages: { + missingHeader: "Missing Apache License header at the top of the file", + }, + }, + create(context) { + const REQUIRED_HEADER = `/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */`; + + return { + Program(node) { + const sourceCode = context.sourceCode || context.getSourceCode(); + const text = sourceCode.getText(); + + if (!text.startsWith(REQUIRED_HEADER)) { + context.report({ + node, + messageId: "missingHeader", + fix(fixer) { + return fixer.insertTextBefore(node, REQUIRED_HEADER + "\n\n"); + }, + }); + } + }, + }; + }, +}; + +export default defineConfig([ + // General + { + ignores: [ + "static/**", + "node_modules/**", + "build/**", + "dist/**", + ".docusaurus/**", + ".github/**", + ], + }, + + // JS + { + files: ["**/*.{js,mjs,cjs,jsx}"], + ...js.configs.recommended, + languageOptions: { globals: { ...globals.browser, ...globals.node } }, + plugins: { + "unused-imports": pluginUnusedImports, + import: pluginImport, + }, + rules: { + "unused-imports/no-unused-imports": "error", + // unused vars (but ignore underscore-prefixed) + "unused-imports/no-unused-vars": [ + "warn", + { + vars: "all", + varsIgnorePattern: "^_", + args: "after-used", + argsIgnorePattern: "^_", + }, + ], + "import/no-duplicates": "error", + "no-unused-vars": "off", + }, + }, + + // React + { + files: ["**/*.{js,jsx}"], + ...pluginReact.configs.flat.recommended, + settings: { + react: { version: "detect" }, + }, + rules: { + "react/prop-types": "off", + "react/react-in-jsx-scope": "off", + "react/jsx-uses-vars": "error", + }, + }, + + // CSS + { + files: ["**/*.css"], + plugins: { css }, + language: "css/css", + extends: ["css/recommended"], + rules: { + "css/no-invalid-properties": "off", + "css/no-important": "off", + "css/use-baseline": "off", + }, + }, + + // Docusaurus + { + files: ["**/*.{js,mjs,cjs,jsx}"], + plugins: { "@docusaurus": pluginDocusaurus }, + rules: { + "@docusaurus/no-html-links": "error", + "@docusaurus/prefer-docusaurus-heading": "error", + "@docusaurus/string-literal-i18n-messages": "error", + // for i18n + // "@docusaurus/no-untranslated-text": ["warn", { ignoredStrings: [] }] Review Comment: Does this rule fail even if i18n is disabled? If it passes trivially in this case then we can probably reduce this to just use the [default recommended config](https://docusaurus.io/docs/api/misc/@docusaurus/eslint-plugin#recommended-config) instead of specifying rules individually. ########## eslint.config.mjs: ########## @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import js from "@eslint/js"; +import globals from "globals"; +import pluginReact from "eslint-plugin-react"; +import css from "@eslint/css"; +import { defineConfig } from "eslint/config"; +import pluginDocusaurus from "@docusaurus/eslint-plugin"; +import pluginUnusedImports from "eslint-plugin-unused-imports"; +import pluginImport from "eslint-plugin-import"; + +const apacheLicenseRule = { + meta: { + type: "problem", + docs: { + description: "Enforce Apache License header in source files", + }, + fixable: "code", + messages: { + missingHeader: "Missing Apache License header at the top of the file", + }, + }, + create(context) { + const REQUIRED_HEADER = `/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */`; + + return { + Program(node) { + const sourceCode = context.sourceCode || context.getSourceCode(); + const text = sourceCode.getText(); + + if (!text.startsWith(REQUIRED_HEADER)) { + context.report({ + node, + messageId: "missingHeader", + fix(fixer) { + return fixer.insertTextBefore(node, REQUIRED_HEADER + "\n\n"); + }, + }); + } + }, + }; + }, +}; + +export default defineConfig([ + // General + { + ignores: [ + "static/**", + "node_modules/**", + "build/**", + "dist/**", + ".docusaurus/**", + ".github/**", + ], + }, + + // JS + { + files: ["**/*.{js,mjs,cjs,jsx}"], + ...js.configs.recommended, + languageOptions: { globals: { ...globals.browser, ...globals.node } }, Review Comment: Cursor made this suggestion, although I don't know enough about javascript to really understand the implications: --- Medium: browser and node globals are both enabled for all JS files, which can hide environment mistakes. This permits Node globals in browser code and browser globals in Node-only files without lint failures. Better practice is split overrides by file location (src/** browser, config/scripts Node). ``` files: ["**/*.{js,mjs,cjs,jsx}"], ...js.configs.recommended, languageOptions: { globals: { ...globals.browser, ...globals.node } }, plugins: { "unused-imports": pluginUnusedImports, import: pluginImport, }, files: ["**/*.{js,mjs,cjs,jsx}"],...js.configs.recommended,languageOptions: { globals: { ...globals.browser, ...globals.node } },plugins: { "unused-imports": pluginUnusedImports, import: pluginImport,}, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
