vehicle-monitor/eslint.config.js

178 lines
4.9 KiB
JavaScript
Raw Permalink Normal View History

2025-02-26 16:31:59 +08:00
import js from '@eslint/js';
import pluginTypeScript from '@typescript-eslint/eslint-plugin';
import * as parserTypeScript from '@typescript-eslint/parser';
import configPrettier from 'eslint-config-prettier';
import { defineFlatConfig } from 'eslint-define-config';
import pluginPrettier from 'eslint-plugin-prettier';
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
import pluginVue from 'eslint-plugin-vue';
import * as parserVue from 'vue-eslint-parser';
2025-02-24 18:23:33 +08:00
export default defineFlatConfig([
2025-02-25 23:14:50 +08:00
{
...js.configs.recommended,
2025-02-26 16:31:59 +08:00
ignores: ['**/.*', 'dist/*', '*.d.ts', 'public/*', 'src/assets/**', 'src/**/iconfont/**'],
2025-02-25 23:14:50 +08:00
languageOptions: {
globals: {
// index.d.ts
2025-02-26 16:31:59 +08:00
RefType: 'readonly',
EmitType: 'readonly',
TargetContext: 'readonly',
ComponentRef: 'readonly',
ElRef: 'readonly',
ForDataType: 'readonly',
AnyFunction: 'readonly',
PropType: 'readonly',
Writable: 'readonly',
Nullable: 'readonly',
NonNullable: 'readonly',
Recordable: 'readonly',
ReadonlyRecordable: 'readonly',
Indexable: 'readonly',
DeepPartial: 'readonly',
Without: 'readonly',
Exclusive: 'readonly',
TimeoutHandle: 'readonly',
IntervalHandle: 'readonly',
Effect: 'readonly',
ChangeEvent: 'readonly',
WheelEvent: 'readonly',
ImportMetaEnv: 'readonly',
Fn: 'readonly',
PromiseFn: 'readonly',
ComponentElRef: 'readonly',
parseInt: 'readonly',
parseFloat: 'readonly',
},
2025-02-25 23:14:50 +08:00
},
plugins: {
2025-02-26 16:31:59 +08:00
prettier: pluginPrettier,
'simple-import-sort': eslintPluginSimpleImportSort,
2025-02-25 23:14:50 +08:00
},
rules: {
...configPrettier.rules,
...pluginPrettier.configs.recommended.rules,
2025-02-26 16:31:59 +08:00
'simple-import-sort/imports': 'error',
'no-debugger': 'off',
'no-unused-vars': [
'error',
2025-02-25 23:14:50 +08:00
{
2025-02-26 16:31:59 +08:00
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
2025-02-25 23:14:50 +08:00
],
2025-02-26 16:31:59 +08:00
'prettier/prettier': [
'error',
2025-02-25 23:14:50 +08:00
{
2025-02-26 16:31:59 +08:00
endOfLine: 'auto',
},
],
},
2025-02-25 23:14:50 +08:00
},
{
2025-02-26 16:31:59 +08:00
files: ['**/*.?([cm])ts', '**/*.?([cm])tsx'],
2025-02-25 23:14:50 +08:00
languageOptions: {
parser: parserTypeScript,
parserOptions: {
2025-02-26 16:31:59 +08:00
sourceType: 'module',
},
2025-02-25 23:14:50 +08:00
},
plugins: {
2025-02-26 16:31:59 +08:00
'@typescript-eslint': pluginTypeScript,
2025-02-25 23:14:50 +08:00
},
rules: {
...pluginTypeScript.configs.strict.rules,
2025-02-26 16:31:59 +08:00
'@typescript-eslint/ban-types': 'off',
2025-03-13 23:01:44 +08:00
'@typescript-eslint/no-redeclare': 'off',
2025-02-26 16:31:59 +08:00
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
2025-02-25 23:14:50 +08:00
{
disallowTypeAnnotations: false,
2025-02-26 16:31:59 +08:00
fixStyle: 'inline-type-imports',
},
2025-02-25 23:14:50 +08:00
],
2025-02-26 16:31:59 +08:00
'@typescript-eslint/no-unused-vars': [
'error',
2025-02-25 23:14:50 +08:00
{
2025-02-26 16:31:59 +08:00
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
},
2025-02-25 23:14:50 +08:00
},
{
2025-02-26 16:31:59 +08:00
files: ['**/*.d.ts'],
2025-02-25 23:14:50 +08:00
rules: {
2025-02-26 16:31:59 +08:00
'eslint-comments/no-unlimited-disable': 'off',
'import/no-duplicates': 'off',
'unused-imports/no-unused-vars': 'off',
},
2025-02-25 23:14:50 +08:00
},
{
2025-02-26 16:31:59 +08:00
files: ['**/*.?([cm])js'],
2025-02-25 23:14:50 +08:00
rules: {
2025-02-26 16:31:59 +08:00
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off',
},
2025-02-25 23:14:50 +08:00
},
{
2025-02-26 16:31:59 +08:00
files: ['**/*.vue'],
2025-02-25 23:14:50 +08:00
languageOptions: {
globals: {
2025-02-26 16:31:59 +08:00
$: 'readonly',
$$: 'readonly',
$computed: 'readonly',
$customRef: 'readonly',
$ref: 'readonly',
$shallowRef: 'readonly',
$toRef: 'readonly',
2025-02-25 23:14:50 +08:00
},
parser: parserVue,
parserOptions: {
ecmaFeatures: {
2025-02-26 16:31:59 +08:00
jsx: true,
2025-02-25 23:14:50 +08:00
},
2025-02-26 16:31:59 +08:00
extraFileExtensions: ['.vue'],
parser: '@typescript-eslint/parser',
sourceType: 'module',
},
2025-02-25 23:14:50 +08:00
},
plugins: {
2025-02-26 16:31:59 +08:00
vue: pluginVue,
2025-02-25 23:14:50 +08:00
},
2025-02-26 16:31:59 +08:00
processor: pluginVue.processors['.vue'],
2025-02-25 23:14:50 +08:00
rules: {
...pluginVue.configs.base.rules,
2025-02-26 16:31:59 +08:00
...pluginVue.configs['vue3-essential'].rules,
...pluginVue.configs['vue3-recommended'].rules,
'no-undef': 'off',
'no-unused-vars': 'off',
'vue/no-v-html': 'off',
'vue/require-default-prop': 'off',
'vue/require-explicit-emits': 'off',
'vue/multi-word-component-names': 'off',
'vue/no-setup-props-reactivity-loss': 'off',
'vue/html-self-closing': [
'error',
2025-02-25 23:14:50 +08:00
{
html: {
2025-02-26 16:31:59 +08:00
void: 'always',
normal: 'always',
component: 'always',
2025-02-25 23:14:50 +08:00
},
2025-02-26 16:31:59 +08:00
svg: 'always',
math: 'always',
},
],
},
},
2025-02-24 18:23:33 +08:00
]);