You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "yuriipalam (via GitHub)" <gi...@apache.org> on 2026/03/05 11:31:27 UTC
[PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
yuriipalam opened a new pull request, #359:
URL: https://github.com/apache/ozone-site/pull/359
## What changes were proposed in this pull request?
Integrate ESLint into the project.
[ESLint](https://eslint.org/) is a static code analyzer, so now we have analyzer during the development.
Both tools were integrated, as well as relevant extensions to them, e.g., [Docusaurus ESLint plugin](https://docusaurus.io/docs/api/misc/@docusaurus/eslint-plugin)
Fixed all the issues that the code analyzers found. Some files had `.js` extension, while they are supposed to have `.jsx` extension, since they have React code inside.
- `pnpm run lint` now runs `eslint` as well.
- `pnpm run lint:fix` now applies auto-fixes from ESLint as well.
Strongly recommend you to check `eslint.config.mjs`, since it sets up the code rules for the project. I also added a custom rule that enforces the license header.
I also updated `CONTRIBUTE.MD` accordingly, the "Quick Start" section and added a new "Linting and Formatting" section.
## What is the link to the Apache Jira?
[HDDS-14770](https://issues.apache.org/jira/browse/HDDS-14770)
## How was this patch tested?
Check off which of the following tests were done on this change. If additional testing was done, please elaborate here as well.
- [ ] The CI checks on my fork are passing
- [X] I verified the rendered content using a local preview
- [X] I manually verified the steps provided in this change work as described
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2920153340
##########
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:
In that case we can probably use this block instead of manually defining the rules so we automatically pick up new rules if Docusaurus adds them later:
```
{
"extends": ["plugin:@docusaurus/recommended"]
}
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2920121687
##########
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:
Ok let's remove it.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895070091
##########
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:
Sure, I agree
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895197951
##########
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:
Well, it might be valid, but not for this project. Docusaurus has SSR/browser duality by design, the mixed globals are intentional and splitting them could produce spurious lint errors in components that legitimately need awareness of both environments. We cannot clearly separate the use of node/browser globals by the file extension/location.
You may want to check this out [https://docusaurus.io/docs/advanced/ssg](https://docusaurus.io/docs/advanced/ssg)
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on PR #359:
URL: https://github.com/apache/ozone-site/pull/359#issuecomment-4111250845
@errose28 I pushed changes that should fix it, could you please approve the workflow?
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2920118875
##########
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:
It will work with yamllint, I verified this in the test above by modifying `compose.yml`. The `.` is resolved before the resulting directory is passed to the process.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895069136
##########
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:
Sure. But I'm not sure if just `.` will work with `yamllint`, since this tool is not an npm package. Therefore, it might not run from the root of the repo if executed not at the root. I'm not sure though, just an assumption
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "devabhishekpal (via GitHub)" <gi...@apache.org>.
devabhishekpal commented on PR #359:
URL: https://github.com/apache/ozone-site/pull/359#issuecomment-4004440409
Thanks a lot for this much needed change @yuriipalam.
Can you please add the rules for using single quotes, spacing between brackets and arrow functions to have brackets always?
I am not sure if this is being currently used or if it would be used in the future, but enforcing this would be great.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on PR #359:
URL: https://github.com/apache/ozone-site/pull/359#issuecomment-4005192008
@devabhishekpal thanks for the review.
For this I'm planning to add Prettier in the next PR. It enforces all the code formatting rules, so they are consistent. What you said could be also enforced by eslint alone, but since I'm planning to add Prettier in the subsequent PR, it's better to do it there. I'll enforce exactly what you've requested.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895201663
##########
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:
`dist` accidentally slipped in, I can remove it. Usually many modern projects use `dist` instead of `build`, but we don't
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895101503
##########
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:
we can have it like this
```json
"import/order": [
"error",
{
groups: [
"builtin", // Node built-ins (path, fs, etc.)
"external", // npm packages (react, @docusaurus/*, etc.)
"internal", // paths configured as internal (e.g. @site/*)
["parent", "sibling", "index"], // relative imports
],
alphabetize: { order: "asc", caseInsensitive: true },
},
],
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895071022
##########
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:
Sure, I can remove this
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895170935
##########
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:
the i18n rule should pass if i18n is not enabled.
there are just 4 rules in total, and we're basically overriding them.
Default:
```js
'@docusaurus/string-literal-i18n-messages': 'error', // for us it's also error
'@docusaurus/no-html-links': 'warn', // we use error
'@docusaurus/prefer-docusaurus-heading': 'warn', // we also use error
```
This one
```js
"@docusaurus/no-untranslated-text": ["warn", { ignoredStrings: [] }]
```
is commented out right now, since we plan want to start using i18n later, as far as I know
we can uncomment it right now, it won't harm
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "yuriipalam (via GitHub)" <gi...@apache.org>.
yuriipalam commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2895101503
##########
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:
we can have it like this
```js
"import/order": [
"error",
{
groups: [
"builtin", // Node built-ins (path, fs, etc.)
"external", // npm packages (react, @docusaurus/*, etc.)
"internal", // paths configured as internal (e.g. @site/*)
["parent", "sibling", "index"], // relative imports
],
alphabetize: { order: "asc", caseInsensitive: true },
},
],
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 merged PR #359:
URL: https://github.com/apache/ozone-site/pull/359
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-14770. [Website] Integrate eslint and run it in github actions [ozone-site]
Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on code in PR #359:
URL: https://github.com/apache/ozone-site/pull/359#discussion_r2920146017
##########
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:
Sure let's add this. I'm not very familiar with best practices on the specific order, but some kind of ordering would help.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org