From 80cd570b1439cadafec5a83d12fa56d85316b431 Mon Sep 17 00:00:00 2001 From: Jakub Hanko <60473007+JakubHanko@users.noreply.github.com> Date: Fri, 24 May 2024 16:37:42 +0200 Subject: [PATCH 1/4] Add ESLint flat config support --- .eslintignore | 7 ------- .eslintrc | 35 ----------------------------------- eslint.config.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 42 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index a471bfa9471..00000000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -dist/* -build/* -coverage/* -public/* -.github/* -node_modules/* -.vscode/* \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index e1f6ba9ee32..00000000000 --- a/.eslintrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", // Specifies the ESLint parser for TypeScript - "plugins": ["@typescript-eslint", "import"], // Includes TypeScript and import plugins - "overrides": [ - { - "files": ["src/**/*.{ts,tsx,js,jsx}"], // Applies these rules to all TypeScript and JavaScript files in the src directory - "rules": { - // General rules that apply to all files - "eqeqeq": ["error", "always"], // Enforces the use of === and !== instead of == and != - "indent": ["error", 2], // Enforces a 2-space indentation - "quotes": ["error", "double"], // Enforces the use of double quotes for strings - "no-var": "error", // Disallows the use of var, enforcing let or const instead - "prefer-const": "error", // Prefers the use of const for variables that are never reassigned - "no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this) - "@typescript-eslint/no-unused-vars": [ "error", { - "args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used. - "ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the rest. - }], - "eol-last": ["error", "always"], // Enforces at least one newline at the end of files - "@typescript-eslint/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax - "semi": "off", // Disables the general semi rule for TypeScript files - "@typescript-eslint/no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax - "brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors - "curly": ["error", "all"], // Enforces the use of curly braces for all control statements - "@typescript-eslint/brace-style": ["error", "1tbs"], - "no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines - "skipBlankLines": false, // Enforces the rule even on blank lines - "ignoreComments": false // Enforces the rule on lines containing comments - }], - "space-before-blocks": ["error", "always"], // Enforces a space before blocks - "keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords - } - } - ] -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000000..571369d9dff --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,42 @@ +import tseslint from '@typescript-eslint/eslint-plugin'; +import parser from '@typescript-eslint/parser'; +import imports from 'eslint-plugin-import'; + +export default [ + { + files: ["src/**/*.{ts,tsx,js,jsx}"], + ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"], + languageOptions: { + parser: parser + }, + plugins: { + imports: imports.configs.recommended, + '@typescript-eslint': tseslint + }, + rules: { + "eqeqeq": ["error", "always"], // Enforces the use of === and !== instead of == and != + "indent": ["error", 2], // Enforces a 2-space indentation + "quotes": ["error", "double"], // Enforces the use of double quotes for strings + "no-var": "error", // Disallows the use of var, enforcing let or const instead + "prefer-const": "error", // Prefers the use of const for variables that are never reassigned + "no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this) + "@typescript-eslint/no-unused-vars": [ "error", { + "args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used. + "ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the rest. + }], + "eol-last": ["error", "always"], // Enforces at least one newline at the end of files + "@typescript-eslint/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax + "semi": "off", // Disables the general semi rule for TypeScript files + "no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax + "brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors + "curly": ["error", "all"], // Enforces the use of curly braces for all control statements + "@typescript-eslint/brace-style": ["error", "1tbs"], + "no-trailing-spaces": ["error", { // Disallows trailing whitespace at the end of lines + "skipBlankLines": false, // Enforces the rule even on blank lines + "ignoreComments": false // Enforces the rule on lines containing comments + }], + "space-before-blocks": ["error", "always"], // Enforces a space before blocks + "keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords + } + } +] \ No newline at end of file From 9a45e46900d7137069e9bb5038b6c195580be0d3 Mon Sep 17 00:00:00 2001 From: Jakub Hanko <60473007+JakubHanko@users.noreply.github.com> Date: Fri, 24 May 2024 16:41:46 +0200 Subject: [PATCH 2/4] Add empty line at the end of config --- eslint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint.config.js b/eslint.config.js index 571369d9dff..d04b7a7176d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -39,4 +39,4 @@ export default [ "keyword-spacing": ["error", { "before": true, "after": true }] // Enforces spacing before and after keywords } } -] \ No newline at end of file +] From ab31247bd84f728d446c8a381611536316a803b8 Mon Sep 17 00:00:00 2001 From: Jakub Hanko <60473007+JakubHanko@users.noreply.github.com> Date: Fri, 24 May 2024 16:54:21 +0200 Subject: [PATCH 3/4] Fix ESLint action --- .github/workflows/eslint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 5dab0886d59..4d3a552d3b9 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -28,4 +28,4 @@ jobs: run: npm ci # Use 'npm ci' to install dependencies - name: eslint # Step to run linters - uses: icrawl/action-eslint@v1 \ No newline at end of file + run: eslint . \ No newline at end of file From d024b840bf3085923216929d8d2958d2386964b1 Mon Sep 17 00:00:00 2001 From: Jakub Hanko <60473007+JakubHanko@users.noreply.github.com> Date: Fri, 24 May 2024 17:03:22 +0200 Subject: [PATCH 4/4] Another try to fix ESLint CI run --- .github/workflows/eslint.yml | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 4d3a552d3b9..32c0ca7707a 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -28,4 +28,4 @@ jobs: run: npm ci # Use 'npm ci' to install dependencies - name: eslint # Step to run linters - run: eslint . \ No newline at end of file + run: npm run eslint-ci \ No newline at end of file diff --git a/package.json b/package.json index a477bbe8cbf..49577e0192d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "test": "vitest run", "test:cov": "vitest run --coverage", "test:watch": "vitest watch --coverage", - "eslint": "eslint --fix ." + "eslint": "eslint --fix .", + "eslint-ci": "eslint ." }, "devDependencies": { "@eslint/js": "^9.3.0",