Repository navigation
Expand file tree
/
Copy patheslint.config.mts
More file actions
171 lines (164 loc) · 5.4 KB
/
Copy patheslint.config.mts
File metadata and controls
171 lines (164 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import eslintJs from '@eslint/js';
import markdown from '@eslint/markdown';
import { defineConfig } from 'eslint/config';
import eslintPluginPackageJson from 'eslint-plugin-package-json';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import eslintPluginVitest from '@vitest/eslint-plugin';
import typescriptEslint from 'typescript-eslint';
const namedRecommendedEslintConfig = {
name: 'eslint/recommended',
...eslintJs.configs.recommended,
};
const typescriptEslintStrictAndStylisticConfigs = [
...typescriptEslint.configs.strictTypeChecked,
...typescriptEslint.configs.stylisticTypeChecked.filter(
({ name }) =>
name !== 'typescript-eslint/base' &&
name !== 'typescript-eslint/eslint-recommended',
),
];
export default defineConfig(
{
name: 'vue-ts-types/ignore-dist',
ignores: ['dist', 'CHANGELOG.md'],
},
eslintPluginPackageJson.configs.recommended,
eslintPluginPackageJson.configs.stylistic,
{
files: ['**/*.ts', '**/*.mts'],
extends: [
namedRecommendedEslintConfig,
...typescriptEslintStrictAndStylisticConfigs,
eslintPluginUnicorn.configs.recommended,
eslintConfigPrettier,
],
},
{
name: 'vue-ts-types/main',
files: ['**/*.ts', '**/*.mts'],
languageOptions: {
ecmaVersion: 'latest',
parserOptions: {
projectService: true,
},
},
linterOptions: {
reportUnusedDisableDirectives: 'error',
reportUnusedInlineConfigs: 'error',
},
rules: {
// Core ESLint rules
'accessor-pairs': 'error',
'camelcase': [
'error',
{
allow: ['Vue2_6', 'Vue2_7'],
},
],
'consistent-return': 'error',
'curly': ['error', 'all'],
'eqeqeq': 'error',
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
'guard-for-in': 'error',
'no-bitwise': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-lonely-if': 'error',
'no-loop-func': 'error',
'no-object-constructor': 'error',
'no-return-assign': 'error',
'no-shadow': 'off', // replaced by @typescript-eslint/no-shadow
'no-template-curly-in-string': 'error',
'no-unsafe-optional-chaining': [
'error',
{ disallowArithmeticOperators: true },
],
'object-shorthand': ['error', 'always', { avoidQuotes: true }],
'prefer-arrow-callback': 'error',
'prefer-template': 'error',
'radix': 'error',
// eslint-plugin-unicorn
'unicorn/filename-case': 'off',
'unicorn/name-replacements': [
'error',
{
replacements: {
prop: false,
props: false,
},
},
],
'unicorn/no-null': 'off',
'unicorn/no-useless-undefined': 'off', // conflicts with consistent-return
// @typescript-eslint/eslint-plugin
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-empty-object-type': [
'error',
{ allowInterfaces: 'with-single-extends' },
],
'@typescript-eslint/no-explicit-any': 'off', // needed for Vue.js types compatibility
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-unnecessary-parameter-property-assignment':
'error',
'@typescript-eslint/no-unnecessary-type-conversion': 'error',
'@typescript-eslint/no-shadow': [
'error',
{ ignoreOnInitialization: true },
],
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
},
},
{
name: 'vue-ts-types/validators',
files: ['src/validators/**/*.ts'],
rules: {
'unicorn/consistent-boolean-name': 'off', // these are Validator functions (or factories thereof), not booleans
},
},
{
name: 'vue-ts-types/tests',
files: ['tests/**/*.spec.ts'],
plugins: {
vitest: eslintPluginVitest,
},
rules: {
...Object.fromEntries(
Object.entries(eslintPluginVitest.configs.all.rules).map(
([ruleName, severity]) => [
ruleName,
severity === 'off' ? 'off' : 'error',
],
),
),
'vitest/consistent-test-filename': 'off', // already covered by specific `include` path
'vitest/max-expects': 'off', // more expect statements are needed for some tests
'vitest/no-importing-vitest-globals': 'off', // conflicts with `vitest/prefer-importing-vitest-globals`
'vitest/padding-around-all': 'off', // already covered by individual `padding` rules
'vitest/prefer-expect-assertions': 'off', // too verbose
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
},
settings: {
vitest: {
typecheck: true,
},
},
},
{
name: 'vue-ts-types/markdown',
files: ['**/*.md'],
language: 'markdown/gfm',
extends: [markdown.configs.recommended],
rules: {
'markdown/no-bare-urls': 'error',
'markdown/no-duplicate-headings': 'error',
},
},
);