Skip to content

Commit

Permalink
upgrade eslint, migrate to esm and flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Aug 22, 2024
1 parent 9e8f82f commit 8246506
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 210 deletions.
51 changes: 0 additions & 51 deletions frontend/.eslintrc.cjs

This file was deleted.

10 changes: 8 additions & 2 deletions frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@
"html.format.wrapLineLength": 0,
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.quoteStyle": "single",
"mochaExplorer.nodeArgv": [
"--loader=ts-node/esm",
"--no-warnings=ExperimentalWarning",
"--experimental-specifier-resolution=node"
],
"mochaExplorer.env": {
"TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\" }",
//"TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\" }",
// "TS_NODE_PROJECT": "./test/tsconfig.json"
},
"mochaExplorer.files": "test/**/*.spec.ts",
"mochaExplorer.require": "ts-node/register",
"eslint.validate": ["typescript", "javascript", "vue"]
"eslint.validate": ["typescript", "javascript", "vue"],
"eslint.useFlatConfig": true
}
97 changes: 97 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// @ts-check
import eslint from "@eslint/js";
import pluginVue from 'eslint-plugin-vue';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
files: ['src/**/*.ts', 'test/**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
],
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
ecmaVersion: 'latest',
sourceType: 'module',
},
},
rules: {
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-unused-vars': 'off', // is checked by noUnusedLocals in tsconfig.json // or use ['error', { 'ignoreRestSiblings': true }]
'no-unused-vars': 'off', // is checked by noUnusedLocals in tsconfig.json
'no-undef': 'off', // types checked by typescript already
'keyword-spacing': ['error', { before: true, after: true}],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true, }],
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0, maxBOF: 0 }],
'object-curly-spacing': ['error', 'always'],
'padded-blocks': ['error', 'never'],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
'space-infix-ops': 'error',
'indent': ['error', 2, { SwitchCase: 1 }],
}
},
{
files: ['test/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off'
}
},
{
files: ['src/**/*.vue'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...pluginVue.configs["flat/recommended"],
],
plugins: {
'@typescript-eslint': tseslint.plugin,
},
languageOptions: {
parserOptions: {
parser: tseslint.parser,
ecmaVersion: 'latest',
sourceType: 'module',
extraFileExtensions: ['.vue'],
ecmaFeatures: {
jsx: true
}
},
},
rules: {
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-unused-vars': 'off', // is checked by noUnusedLocals in tsconfig.json // or use ['error', { 'ignoreRestSiblings': true }]
'no-unused-vars': 'off', // is checked by noUnusedLocals in tsconfig.json
'no-undef': 'off', // types checked by typescript already
'keyword-spacing': ['error', { before: true, after: true}],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true, }],
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0, maxBOF: 0 }],
'object-curly-spacing': ['error', 'always'],
'padded-blocks': ['error', 'never'],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
'space-infix-ops': 'error',
'indent': ['error', 2, { SwitchCase: 1 }],
'vue/block-tag-newline': ['error', { singleline: 'consistent', multiline: 'consistent', }],
'vue/html-closing-bracket-spacing': 'off',
'vue/html-self-closing': 'off',
'vue/max-attributes-per-line': 'off',
'vue/padding-line-between-blocks': 'error',
'vue/singleline-html-element-content-newline': 'off',
'vue/space-infix-ops': 'error',
},
}
);
Loading

0 comments on commit 8246506

Please sign in to comment.