From b601671395bd04cd279fd3a4054198188a9cd0ce Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 29 Oct 2024 10:05:40 +0100 Subject: [PATCH] chore: migrate eslint config --- frontend/.eslintrc.cjs | 63 ---------------------------- frontend/eslint.config.js | 88 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 63 deletions(-) delete mode 100644 frontend/.eslintrc.cjs create mode 100644 frontend/eslint.config.js diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs deleted file mode 100644 index c64e98a65..000000000 --- a/frontend/.eslintrc.cjs +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint-env node */ -require('@rushstack/eslint-patch/modern-module-resolution') - -module.exports = { - 'root': true, - 'env': { - 'browser': true, - 'es2022': true, - 'node': true, - }, - 'extends': [ - 'eslint:recommended', - 'plugin:vue/vue3-recommended', - '@vue/eslint-config-typescript/recommended', - ], - 'rules': { - 'quotes': ['error', 'single'], - 'comma-dangle': ['error', 'always-multiline'], - 'semi': ['error', 'never'], - - 'vue/v-on-event-hyphenation': ['warn', 'never', { 'autofix': true }], - 'vue/multi-word-component-names': 'off', - - // uncategorized rules: - 'vue/component-api-style': ['error', ['script-setup']], - 'vue/component-name-in-template-casing': ['error', 'PascalCase', { - 'globals': ['RouterView', 'RouterLink', 'Icon', 'Notifications', 'Modal', 'Card'], - }], - 'vue/custom-event-name-casing': ['error', 'camelCase'], - 'vue/define-macros-order': 'error', - 'vue/match-component-file-name': ['error', { - 'extensions': ['.js', '.jsx', '.ts', '.tsx', '.vue'], - 'shouldMatchCase': true, - }], - 'vue/no-boolean-default': ['warn', 'default-false'], - 'vue/match-component-import-name': 'error', - 'vue/prefer-separate-static-class': 'warn', - - 'vue/padding-line-between-blocks': 'error', - 'vue/next-tick-style': ['error', 'promise'], - 'vue/block-lang': [ - 'error', - { 'script': { 'lang': 'ts' } }, - ], - 'vue/no-duplicate-attr-inheritance': 'error', - 'vue/no-empty-component-block': 'error', - 'vue/html-indent': ['error', 'tab'], - - // vue3 - 'vue/no-ref-object-reactivity-loss': 'error', - 'vue/no-setup-props-reactivity-loss': 'warn', // TODO: switch to error after vite `propsDestructure` is removed - }, - 'parser': 'vue-eslint-parser', - 'parserOptions': { - 'parser': '@typescript-eslint/parser', - 'ecmaVersion': 'latest', - 'tsconfigRootDir': __dirname, - }, - 'ignorePatterns': [ - '*.test.*', - 'cypress/*', - ], -} \ No newline at end of file diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js new file mode 100644 index 000000000..f0da7af56 --- /dev/null +++ b/frontend/eslint.config.js @@ -0,0 +1,88 @@ +import pluginVue from 'eslint-plugin-vue' +import js from '@eslint/js' +import vueTsEslintConfig from '@vue/eslint-config-typescript' + +export default [ + js.configs.recommended, + ...pluginVue.configs['flat/recommended'], + ...vueTsEslintConfig(), + { + ignores: [ + '**/*.test.ts', + './cypress', + ], + }, + { + rules: { + 'quotes': ['error', 'single'], + 'comma-dangle': ['error', 'always-multiline'], + 'semi': ['error', 'never'], + + 'vue/v-on-event-hyphenation': ['warn', 'never', {'autofix': true}], + 'vue/multi-word-component-names': 'off', + + // uncategorized rules: + 'vue/component-api-style': ['error', ['script-setup']], + 'vue/component-name-in-template-casing': ['error', 'PascalCase', { + 'globals': ['RouterView', 'RouterLink', 'Icon', 'Notifications', 'Modal', 'Card'], + }], + 'vue/custom-event-name-casing': ['error', 'camelCase'], + 'vue/define-macros-order': 'error', + 'vue/match-component-file-name': ['error', { + 'extensions': ['.js', '.jsx', '.ts', '.tsx', '.vue'], + 'shouldMatchCase': true, + }], + 'vue/no-boolean-default': ['warn', 'default-false'], + 'vue/match-component-import-name': 'error', + 'vue/prefer-separate-static-class': 'warn', + + 'vue/padding-line-between-blocks': 'error', + 'vue/next-tick-style': ['error', 'promise'], + 'vue/block-lang': [ + 'error', + {'script': {'lang': 'ts'}}, + ], + 'vue/no-duplicate-attr-inheritance': 'error', + 'vue/no-empty-component-block': 'error', + 'vue/html-indent': ['error', 'tab'], + + // vue3 + 'vue/no-ref-object-reactivity-loss': 'error', + 'vue/no-setup-props-reactivity-loss': 'warn', // TODO: switch to error after vite `propsDestructure` is removed + + '@typescript-eslint/no-unused-vars': [ + 'error', + { + // 'args': 'all', + // 'argsIgnorePattern': '^_', + 'caughtErrors': 'all', + 'caughtErrorsIgnorePattern': '^_', + // 'destructuredArrayIgnorePattern': '^_', + 'varsIgnorePattern': '^_', + 'ignoreRestSiblings': true, + }, + ], + }, + + // files: ['*.vue', '**/*.vue'], + languageOptions: { + parserOptions: { + parser: '@typescript-eslint/parser', + ecmaVersion: 'latest', + tsconfigRootDir: '.', + }, + }, + + + // 'parser': 'vue-eslint-parser', + // 'parserOptions': { + // 'parser': '@typescript-eslint/parser', + // 'ecmaVersion': 'latest', + // 'tsconfigRootDir': __dirname, + // }, + // 'ignorePatterns': [ + // 'cypress/*', + // ], + }, + +] \ No newline at end of file