From 29888b945f275239f36f3edf38254f10bf6de658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20F=C3=BCrhoff?= <12294151+imagoiq@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:40:27 +0100 Subject: [PATCH] chore(*): Fix eslint configs (#2140) Co-authored-by: Philipp Gfeller --- .vscode/settings.json | 2 - packages/components-react/.eslintignore | 2 + packages/components-react/.eslintrc.json | 45 ++++++----- packages/components/.eslintignore | 5 ++ packages/components/.eslintrc.js | 77 +++++++++++++++++++ packages/components/.eslintrc.json | 75 ------------------ .../components/cypress/e2e/collapsible.cy.ts | 4 +- packages/components/cypress/e2e/tooltip.cy.ts | 4 +- packages/components/tsconfig.eslint.json | 9 +-- packages/demo/.eslintignore | 2 + packages/demo/.eslintrc.js | 74 ++++++++---------- packages/internet-header/.eslintignore | 10 +++ packages/internet-header/.eslintrc.js | 23 ++++++ packages/internet-header/.eslintrc.json | 24 ------ packages/internet-header/tsconfig.eslint.json | 9 +-- packages/internet-header/tsconfig.json | 16 +--- .../projects/intranet-header/.eslintrc.js | 36 +++++++++ .../projects/intranet-header/.eslintrc.json | 38 --------- 18 files changed, 223 insertions(+), 232 deletions(-) create mode 100644 packages/components-react/.eslintignore create mode 100644 packages/components/.eslintrc.js delete mode 100644 packages/components/.eslintrc.json create mode 100644 packages/demo/.eslintignore create mode 100644 packages/internet-header/.eslintignore create mode 100644 packages/internet-header/.eslintrc.js delete mode 100644 packages/internet-header/.eslintrc.json create mode 100644 packages/intranet-header-workspace/projects/intranet-header/.eslintrc.js delete mode 100644 packages/intranet-header-workspace/projects/intranet-header/.eslintrc.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 07d13e35c9..2c63c08510 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,2 @@ { - // Fixes tsconfig not found error in nested .eslintrc.json files with relative paths - "eslint.workingDirectories": ["packages/intranet-header-workspace"] } diff --git a/packages/components-react/.eslintignore b/packages/components-react/.eslintignore new file mode 100644 index 0000000000..85249e592f --- /dev/null +++ b/packages/components-react/.eslintignore @@ -0,0 +1,2 @@ +dist +src/components/stencil-generated diff --git a/packages/components-react/.eslintrc.json b/packages/components-react/.eslintrc.json index 7c58c45636..4a1c10433e 100644 --- a/packages/components-react/.eslintrc.json +++ b/packages/components-react/.eslintrc.json @@ -1,23 +1,28 @@ { - "env": { - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended" - ], - "overrides": [ - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": [ - "react", - "@typescript-eslint" - ], - "rules": { + "env": { + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/recommended" + ], + "overrides": [ + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": [ + "react", + "@typescript-eslint" + ], + "settings": { + "react": { + "version": "detect" } + }, + "rules": { + } } diff --git a/packages/components/.eslintignore b/packages/components/.eslintignore index a6c7f6e4f2..61a1507048 100644 --- a/packages/components/.eslintignore +++ b/packages/components/.eslintignore @@ -2,3 +2,8 @@ dist loader www +.stencil +cypress +stencil.config.ts +cypress.config.js +.eslintrc.js diff --git a/packages/components/.eslintrc.js b/packages/components/.eslintrc.js new file mode 100644 index 0000000000..04758f327b --- /dev/null +++ b/packages/components/.eslintrc.js @@ -0,0 +1,77 @@ +module.exports = { + env: { + browser: true, + node: true, + es2021: true, + }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@stencil-community/recommended', + ], + overrides: [], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + tsconfigRootDir: __dirname, + project: 'tsconfig.eslint.json', + }, + plugins: ['@typescript-eslint'], + rules: { + 'indent': [ + 'error', + 2, + { + SwitchCase: 1, + }, + ], + 'quotes': ['error', 'single'], + 'semi': ['error', 'always'], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + caughtErrors: 'none', + destructuredArrayIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + '@stencil-community/strict-boolean-conditions': 'off', + '@stencil-community/required-prefix': ['error', ['post-']], + '@stencil-community/async-methods': 'error', + '@stencil-community/decorators-context': 'error', + '@stencil-community/decorators-style': [ + 'error', + { + prop: 'inline', + state: 'inline', + element: 'inline', + event: 'inline', + method: 'multiline', + watch: 'multiline', + listen: 'multiline', + }, + ], + '@stencil-community/class-pattern': [ + 'error', + { + pattern: '^Post.*(?!Component)$', + }, + ], + '@stencil-community/element-type': 'error', + '@stencil-community/host-data-deprecated': 'error', + '@stencil-community/methods-must-be-public': 'error', + '@stencil-community/no-unused-watch': 'error', + '@stencil-community/own-methods-must-be-private': 'error', + '@stencil-community/own-props-must-be-private': 'error', + '@stencil-community/prefer-vdom-listener': 'error', + '@stencil-community/props-must-be-public': 'error', + '@stencil-community/props-must-be-readonly': 'error', + '@stencil-community/render-returns-host': 'error', + '@stencil-community/required-jsdoc': 'error', + '@stencil-community/reserved-member-names': 'error', + '@stencil-community/single-export': 'error', + '@stencil-community/strict-mutable': 'error', + 'react/jsx-no-bind': 'off', + }, +}; diff --git a/packages/components/.eslintrc.json b/packages/components/.eslintrc.json deleted file mode 100644 index b741c91ffb..0000000000 --- a/packages/components/.eslintrc.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@stencil-community/recommended" - ], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module", - "project": "./tsconfig.eslint.json" - }, - "plugins": ["@typescript-eslint"], - "rules": { - "indent": [ - "error", - 2, - { - "SwitchCase": 1 - } - ], - "quotes": ["error", "single"], - "semi": ["error", "always"], - "@typescript-eslint/no-unused-vars": [ - "error", - { - "caughtErrors": "none", - "destructuredArrayIgnorePattern": "^_", - "ignoreRestSiblings": true - } - ], - "@stencil-community/strict-boolean-conditions": "off", - "@stencil-community/required-prefix": ["error", ["post-"]], - "@stencil-community/async-methods": "error", - "@stencil-community/decorators-context": "error", - "@stencil-community/decorators-style": [ - "error", - { - "prop": "inline", - "state": "inline", - "element": "inline", - "event": "inline", - "method": "multiline", - "watch": "multiline", - "listen": "multiline" - } - ], - "@stencil-community/class-pattern": [ - "error", - { - "pattern": "^Post.*(?!Component)$" - } - ], - "@stencil-community/element-type": "error", - "@stencil-community/host-data-deprecated": "error", - "@stencil-community/methods-must-be-public": "error", - "@stencil-community/no-unused-watch": "error", - "@stencil-community/own-methods-must-be-private": "error", - "@stencil-community/own-props-must-be-private": "error", - "@stencil-community/prefer-vdom-listener": "error", - "@stencil-community/props-must-be-public": "error", - "@stencil-community/props-must-be-readonly": "error", - "@stencil-community/render-returns-host": "error", - "@stencil-community/required-jsdoc": "error", - "@stencil-community/reserved-member-names": "error", - "@stencil-community/single-export": "error", - "@stencil-community/strict-mutable": "error", - "react/jsx-no-bind": "off" - } -} diff --git a/packages/components/cypress/e2e/collapsible.cy.ts b/packages/components/cypress/e2e/collapsible.cy.ts index 38ca2534ab..11ca46e5f6 100644 --- a/packages/components/cypress/e2e/collapsible.cy.ts +++ b/packages/components/cypress/e2e/collapsible.cy.ts @@ -45,7 +45,7 @@ describe('collapsible', () => { cy.get('@collapse').should(`be.hidden`); }); - it("should adapt the header's aria-expanded attribute after collapsing", () => { + it('should adapt the header\'s aria-expanded attribute after collapsing', () => { cy.get('@header').click(); cy.checkAriaExpanded('@collapse', 'false'); }); @@ -55,7 +55,7 @@ describe('collapsible', () => { cy.get('@collapse').should(`be.visible`); }); - it("should adapt the header's aria-expanded attribute after expanding", () => { + it('should adapt the header\'s aria-expanded attribute after expanding', () => { cy.get('@header').dblclick(); cy.checkAriaExpanded('@collapse', 'true'); }); diff --git a/packages/components/cypress/e2e/tooltip.cy.ts b/packages/components/cypress/e2e/tooltip.cy.ts index cd619decdf..44214dc76f 100644 --- a/packages/components/cypress/e2e/tooltip.cy.ts +++ b/packages/components/cypress/e2e/tooltip.cy.ts @@ -21,8 +21,8 @@ describe('tooltips', () => { cy.wait(10); cy.get('@tooltip') .should('have.css', 'left') - .then((v: any) => { - expect(parseInt(v)).to.be.greaterThan(150); + .then((v: unknown) => { + expect(parseInt(v as string)).to.be.greaterThan(150); }); }); }); diff --git a/packages/components/tsconfig.eslint.json b/packages/components/tsconfig.eslint.json index 1b93f64de1..13fc8ef9dc 100644 --- a/packages/components/tsconfig.eslint.json +++ b/packages/components/tsconfig.eslint.json @@ -1,10 +1,5 @@ { "extends": "./tsconfig.json", - "include": [ - "src", - "**/tests" - ], - "exclude": [ - "node_modules" - ] + "include": ["src", "**/tests"], + "exclude": ["node_modules"] } diff --git a/packages/demo/.eslintignore b/packages/demo/.eslintignore new file mode 100644 index 0000000000..b59b85cf92 --- /dev/null +++ b/packages/demo/.eslintignore @@ -0,0 +1,2 @@ +.angular +dist diff --git a/packages/demo/.eslintrc.js b/packages/demo/.eslintrc.js index cac0c0bc93..d3dd9318ce 100644 --- a/packages/demo/.eslintrc.js +++ b/packages/demo/.eslintrc.js @@ -1,51 +1,41 @@ module.exports = { - "root": true, - "ignorePatterns": [ - "projects/**/*" - ], - "overrides": [ + root: true, + ignorePatterns: ['projects/**/*'], + overrides: [ { - "files": [ - "*.ts" - ], - "parserOptions": { - "project": [ - "tsconfig.json" - ], - "tsconfigRootDir": __dirname, - "createDefaultProgram": true + files: ['*.ts'], + parserOptions: { + project: ['tsconfig.json'], + tsconfigRootDir: __dirname, + createDefaultProgram: true, }, - "extends": [ - "plugin:@angular-eslint/recommended", - "plugin:@angular-eslint/template/process-inline-templates" + extends: [ + 'plugin:@angular-eslint/recommended', + 'plugin:@angular-eslint/template/process-inline-templates', ], - "rules": { - "@angular-eslint/directive-selector": [ - "error", + rules: { + '@angular-eslint/directive-selector': [ + 'error', { - "type": "attribute", - "prefix": "app", - "style": "camelCase" - } + type: 'attribute', + prefix: 'app', + style: 'camelCase', + }, ], - "@angular-eslint/component-selector": [ - "error", + '@angular-eslint/component-selector': [ + 'error', { - "type": "element", - "prefix": "app", - "style": "kebab-case" - } - ] - } + type: 'element', + prefix: 'app', + style: 'kebab-case', + }, + ], + }, }, { - "files": [ - "*.html" - ], - "extends": [ - "plugin:@angular-eslint/template/recommended" - ], - "rules": {} - } - ] -} + files: ['*.html'], + extends: ['plugin:@angular-eslint/template/recommended'], + rules: {}, + }, + ], +}; diff --git a/packages/internet-header/.eslintignore b/packages/internet-header/.eslintignore new file mode 100644 index 0000000000..f88a9adbbe --- /dev/null +++ b/packages/internet-header/.eslintignore @@ -0,0 +1,10 @@ +.stencil +loader +www +dist +node_modules +stencil.config.ts +cypress.config.js +jest.config.js +src/assets +.eslintrc.js diff --git a/packages/internet-header/.eslintrc.js b/packages/internet-header/.eslintrc.js new file mode 100644 index 0000000000..d3bba2e6fa --- /dev/null +++ b/packages/internet-header/.eslintrc.js @@ -0,0 +1,23 @@ +module.exports = { + extends: ['plugin:@stencil-community/recommended'], + parserOptions: { + sourceType: 'module', + ecmaVersion: 2020, + tsconfigRootDir: __dirname, + project: 'tsconfig.eslint.json', + }, + rules: { + '@stencil-community/element-type': 1, + // Needed for DropdownElement + '@stencil/decorators-context': 0, + // This is a broken rule with eslint 8 (https://github.com/stencil-community/stencil-eslint/issues/60) + '@stencil/own-methods-must-be-private': 0, + // Seems to be buggy as well + '@stencil/async-methods': 0, + // Also buggy + '@stencil/no-unused-watch': 0, + // Buggy + 'react/jsx-no-bind': 0, + // No performance problem anymore https://medium.com/@ryanflorence/react-inline-functions-and-performance-bdff784f5578 + }, +}; diff --git a/packages/internet-header/.eslintrc.json b/packages/internet-header/.eslintrc.json deleted file mode 100644 index 144f980038..0000000000 --- a/packages/internet-header/.eslintrc.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": [ - "plugin:@stencil-community/recommended" - ], - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 2020, - "project": "./tsconfig.eslint.json" - }, - "rules": { - "@stencil-community/element-type": 1, - // Needed for DropdownElement - "@stencil/decorators-context": 0, - // This is a broken rule with eslint 8 (https://github.com/stencil-community/stencil-eslint/issues/60) - "@stencil/own-methods-must-be-private": 0, - // Seems to be buggy as well - "@stencil/async-methods": 0, - // Also buggy - "@stencil/no-unused-watch": 0, - // Buggy - "react/jsx-no-bind": 0 - // No performance problem anymore https://medium.com/@ryanflorence/react-inline-functions-and-performance-bdff784f5578 - } -} diff --git a/packages/internet-header/tsconfig.eslint.json b/packages/internet-header/tsconfig.eslint.json index 1b93f64de1..450adaefc1 100644 --- a/packages/internet-header/tsconfig.eslint.json +++ b/packages/internet-header/tsconfig.eslint.json @@ -1,10 +1,5 @@ { "extends": "./tsconfig.json", - "include": [ - "src", - "**/tests" - ], - "exclude": [ - "node_modules" - ] + "include": ["src", "**/tests", "cypress"], + "exclude": ["node_modules"] } diff --git a/packages/internet-header/tsconfig.json b/packages/internet-header/tsconfig.json index 4fdcf6f8f4..5d64d12fc2 100644 --- a/packages/internet-header/tsconfig.json +++ b/packages/internet-header/tsconfig.json @@ -4,11 +4,7 @@ "allowUnreachableCode": false, "declaration": true, "experimentalDecorators": true, - "lib": [ - "dom", - "DOM.Iterable", - "es2017" - ], + "lib": ["dom", "DOM.Iterable", "es2017"], "moduleResolution": "node", "module": "esnext", "target": "es2017", @@ -20,12 +16,6 @@ "strictNullChecks": true, "skipLibCheck": true }, - "include": [ - "src" - ], - "exclude": [ - "node_modules", - "**/tests", - "**/*.spec.*" - ] + "include": ["src"], + "exclude": ["node_modules", "**/tests", "**/*.spec.*"] } diff --git a/packages/intranet-header-workspace/projects/intranet-header/.eslintrc.js b/packages/intranet-header-workspace/projects/intranet-header/.eslintrc.js new file mode 100644 index 0000000000..e7eed4974d --- /dev/null +++ b/packages/intranet-header-workspace/projects/intranet-header/.eslintrc.js @@ -0,0 +1,36 @@ +module.exports = { + extends: '../../.eslintrc.json', + ignorePatterns: ['!**/*', 'node_modules'], + overrides: [ + { + files: ['*.ts'], + parserOptions: { + tsconfigRootDir: __dirname, + project: ['tsconfig.lib.json', 'tsconfig.spec.json'], + createDefaultProgram: true, + }, + rules: { + '@angular-eslint/directive-selector': [ + 'error', + { + type: 'attribute', + prefix: 'sp', + style: 'camelCase', + }, + ], + '@angular-eslint/component-selector': [ + 'error', + { + type: 'element', + prefix: 'sp', + style: 'kebab-case', + }, + ], + }, + }, + { + files: ['*.html'], + rules: {}, + }, + ], +}; diff --git a/packages/intranet-header-workspace/projects/intranet-header/.eslintrc.json b/packages/intranet-header-workspace/projects/intranet-header/.eslintrc.json deleted file mode 100644 index c54fc5e0ad..0000000000 --- a/packages/intranet-header-workspace/projects/intranet-header/.eslintrc.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "extends": "../../.eslintrc.json", - "ignorePatterns": ["!**/*", "node_modules"], - "overrides": [ - { - "files": ["*.ts"], - "parserOptions": { - "project": [ - "projects/intranet-header/tsconfig.lib.json", - "projects/intranet-header/tsconfig.spec.json" - ], - "createDefaultProgram": true - }, - "rules": { - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "sp", - "style": "camelCase" - } - ], - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "sp", - "style": "kebab-case" - } - ] - } - }, - { - "files": ["*.html"], - "rules": {} - } - ] -}