From 0fa7884d8d725c5025c6b7ad4fa1ffaa404d242e Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 20 Sep 2024 16:27:42 +0200 Subject: [PATCH] Update linter configs --- gui/.eslintignore | 4 - gui/.eslintrc.js | 120 ----------------------------- gui/.prettierignore | 2 - gui/.prettierrc.yml | 11 --- gui/eslint.config.mjs | 166 ++++++++++++++++++++++++++++++++++++++++ gui/prettier.config.mjs | 7 ++ 6 files changed, 173 insertions(+), 137 deletions(-) delete mode 100644 gui/.eslintignore delete mode 100644 gui/.eslintrc.js delete mode 100644 gui/.prettierignore delete mode 100644 gui/.prettierrc.yml create mode 100644 gui/eslint.config.mjs create mode 100644 gui/prettier.config.mjs diff --git a/gui/.eslintignore b/gui/.eslintignore deleted file mode 100644 index 07b7d976c245..000000000000 --- a/gui/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -.eslintrc.js -gulpfile.js -init.js -tasks/*.js diff --git a/gui/.eslintrc.js b/gui/.eslintrc.js deleted file mode 100644 index 4e4b1e0abe7b..000000000000 --- a/gui/.eslintrc.js +++ /dev/null @@ -1,120 +0,0 @@ -const namingConvention = [ - { - selector: 'default', - format: ['camelCase'], - }, - { - selector: 'variable', - modifiers: ['const'], - format: ['camelCase', 'PascalCase', 'UPPER_CASE'], - leadingUnderscore: 'allow', - }, - { - selector: 'variableLike', - format: ['camelCase'], - leadingUnderscore: 'allow', - }, - { - selector: 'import', - format: ['camelCase', 'PascalCase', 'snake_case'], - }, - { - selector: 'parameter', - format: ['camelCase', 'PascalCase'], - leadingUnderscore: 'allow', - }, - { - selector: 'function', - format: ['camelCase', 'PascalCase'], - }, - { - selector: 'memberLike', - format: ['camelCase'], - }, - { - selector: 'typeProperty', - format: ['camelCase'], - filter: { - regex: "^(data-testid|aria-labelledby|aria-describedby)$", - match: false, - }, - }, - { - selector: 'typeLike', - format: ['PascalCase'], - }, - { - selector: 'property', - format: null, - }, -]; - -const memberOrdering = { - default: [ - 'public-field', - 'protected-field', - 'private-field', - - 'public-constructor', - 'protected-constructor', - 'private-constructor', - - 'public-method', - 'protected-method', - 'private-method', - ], -}; - -module.exports = { - env: { - es6: true, - node: true, - }, - parserOptions: { - parser: '@typescript-eslint/parser', - project: './tsconfig.json', - tsconfigRootDir: __dirname, - ecmaVersion: '2018', - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - ignorePatterns: ['test/*', 'scripts/*'], - plugins: ['prettier', 'simple-import-sort'], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react/recommended', - 'plugin:react/jsx-runtime', - ], - settings: { - react: { - createClass: 'createReactClass', - pragma: 'React', - version: 'detect', - }, - }, - rules: { - quotes: ['error', 'single', { avoidEscape: true }], - 'prettier/prettier': 'error', - '@typescript-eslint/no-unused-vars': [ - 'error', - { argsIgnorePattern: '^_', ignoreRestSiblings: true }, - ], - '@typescript-eslint/require-await': 'error', - '@typescript-eslint/no-floating-promises': 'error', - '@typescript-eslint/no-unused-expressions': 'error', - '@typescript-eslint/member-ordering': ['error', memberOrdering], - 'no-return-await': 'error', - 'react/jsx-no-bind': 'error', - '@typescript-eslint/naming-convention': ['error', ...namingConvention], - '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': false }], - 'simple-import-sort/imports': 'error', - - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - 'react/prop-types': 'off', - }, -}; diff --git a/gui/.prettierignore b/gui/.prettierignore deleted file mode 100644 index b38db2f296ff..000000000000 --- a/gui/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -build/ diff --git a/gui/.prettierrc.yml b/gui/.prettierrc.yml deleted file mode 100644 index 7c4217913d08..000000000000 --- a/gui/.prettierrc.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# .prettierrc.yml -# see: https://prettier.io/docs/en/options.html -printWidth: 100 -semi: true -singleQuote: true -trailingComma: all -bracketSpacing: true -jsxBracketSameLine: true -arrowParens: always -proseWrap: always diff --git a/gui/eslint.config.mjs b/gui/eslint.config.mjs new file mode 100644 index 000000000000..5c2b5d848ca5 --- /dev/null +++ b/gui/eslint.config.mjs @@ -0,0 +1,166 @@ +import eslint from '@eslint/js'; +import prettier from 'eslint-plugin-prettier/recommended'; +import react from 'eslint-plugin-react'; +import simpleImportSort from 'eslint-plugin-simple-import-sort'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; + +const namingConvention = [ + { + selector: 'default', + format: ['camelCase'], + }, + { + selector: 'variable', + modifiers: ['const'], + format: ['camelCase', 'PascalCase', 'UPPER_CASE'], + leadingUnderscore: 'allow', + }, + { + selector: 'variableLike', + format: ['camelCase'], + leadingUnderscore: 'allow', + }, + { + selector: 'import', + format: ['camelCase', 'PascalCase', 'snake_case'], + }, + { + selector: 'parameter', + format: ['camelCase', 'PascalCase'], + leadingUnderscore: 'allow', + }, + { + selector: 'function', + format: ['camelCase', 'PascalCase'], + }, + { + selector: 'memberLike', + format: ['camelCase'], + }, + { + selector: 'typeProperty', + format: ['camelCase'], + filter: { + regex: '^(data-testid|aria-labelledby|aria-describedby)$', + match: false, + }, + }, + { + selector: 'typeLike', + format: ['PascalCase'], + }, + { + selector: 'property', + format: null, + }, +]; + +const memberOrdering = { + default: [ + 'public-field', + 'protected-field', + 'private-field', + + 'public-constructor', + 'protected-constructor', + 'private-constructor', + + 'public-method', + 'protected-method', + 'private-method', + ], +}; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + react.configs.flat.recommended, + prettier, + { ignores: ['build/*'] }, + { + settings: { + react: { + createClass: 'createReactClass', + pragma: 'React', + version: 'detect', + }, + }, + }, + { + files: ['**/*'], + ignores: ['src/renderer/**/*'], + languageOptions: { + globals: globals.node, + }, + }, + { + files: ['src/renderer/**/*'], + languageOptions: { + globals: globals.browser, + }, + }, + { + files: ['test/**/*'], + languageOptions: { + globals: globals.mocha, + }, + }, + { + files: ['src/**/*.{js,mjs,ts,tsx}'], + languageOptions: { + parserOptions: { + parser: '@typescript-eslint/parser', + project: './tsconfig.json', + ecmaVersion: '2018', + sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, + }, + }, + rules: { + '@typescript-eslint/require-await': 'error', + '@typescript-eslint/no-floating-promises': 'error', + }, + }, + { + files: ['**/*.{js,mjs,ts,tsx}'], + plugins: { + 'simple-import-sort': simpleImportSort, + }, + rules: { + quotes: ['error', 'single', { avoidEscape: true }], + // 'prettier/prettier': 'error', + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_', ignoreRestSiblings: true }, + ], + '@typescript-eslint/no-unused-expressions': 'error', + '@typescript-eslint/member-ordering': ['error', memberOrdering], + 'no-return-await': 'error', + 'react/jsx-no-bind': 'error', + '@typescript-eslint/naming-convention': ['error', ...namingConvention], + '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': false }], + 'simple-import-sort/imports': 'error', + + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + 'react/prop-types': 'off', + 'react/react-in-jsx-scope': 'off', + }, + }, + { + files: ['test/**/*.spec.ts'], + rules: { + '@typescript-eslint/no-unused-expressions': 'off', + }, + }, + { + files: ['tasks/*', 'scripts/*', 'gulpfile.js', 'init.js'], + rules: { + '@typescript-eslint/no-require-imports': 'off', + }, + }, +); diff --git a/gui/prettier.config.mjs b/gui/prettier.config.mjs new file mode 100644 index 000000000000..150678b82558 --- /dev/null +++ b/gui/prettier.config.mjs @@ -0,0 +1,7 @@ +// see: https://prettier.io/docs/en/options.html +export default { + printWidth: 100, + singleQuote: true, + bracketSameLine: true, + proseWrap: 'always', +};