eslint-plugin-stamhoofd 2.118.1 → 2.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -6
- package/src/configs/default.js +11 -11
- package/src/configs/frontend.js +39 -26
- package/src/configs/node.js +23 -10
- package/src/configs/typescript.js +34 -30
- package/src/index.js +58 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-stamhoofd",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.120.0",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "UNLICENCED",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -14,13 +14,15 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@eslint/js": "^9.11.1",
|
|
16
16
|
"@stylistic/eslint-plugin": "^2.8.0",
|
|
17
|
+
"@vitest/eslint-plugin": "^1.6.12",
|
|
17
18
|
"eslint": "^9.11.1",
|
|
18
19
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
19
20
|
"eslint-plugin-import": "^2.32.0",
|
|
20
|
-
"eslint-plugin-
|
|
21
|
-
"eslint-plugin-
|
|
22
|
-
"eslint-plugin-vue": "^
|
|
23
|
-
"typescript-eslint": "^8.
|
|
21
|
+
"eslint-plugin-n": "^17.24.0",
|
|
22
|
+
"eslint-plugin-regexp": "^3.1.0",
|
|
23
|
+
"eslint-plugin-vue": "^10.8.0",
|
|
24
|
+
"typescript-eslint": "^8.57.1",
|
|
25
|
+
"vue-eslint-parser": "^10.4.0"
|
|
24
26
|
},
|
|
25
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "f38f79c15ce16b0c8c14743ff3eb61feda5a18d4"
|
|
26
28
|
}
|
package/src/configs/default.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
rules: {
|
|
4
|
+
'no-console': 'off',
|
|
5
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
6
|
+
'sort-imports': 'off',
|
|
7
|
+
'keyword-spacing': 'warn',
|
|
8
|
+
'eqeqeq': ['warn', 'always'],
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
];
|
package/src/configs/frontend.js
CHANGED
|
@@ -1,38 +1,51 @@
|
|
|
1
|
-
import pluginVue from 'eslint-plugin-vue'
|
|
1
|
+
import pluginVue from 'eslint-plugin-vue';
|
|
2
|
+
import globals from 'globals';
|
|
2
3
|
import tseslint from 'typescript-eslint';
|
|
3
4
|
|
|
4
|
-
|
|
5
5
|
export default [
|
|
6
|
-
...pluginVue.configs['flat/recommended'],
|
|
7
6
|
{
|
|
8
|
-
files: ['*.vue', '**/*.vue'],
|
|
9
7
|
languageOptions: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
//sourceType: 'module',
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.browser,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
...pluginVue.configs['flat/recommended'].map(f => {
|
|
15
|
+
return {
|
|
16
|
+
...f,
|
|
17
|
+
files: ['*.ts', '**/*.ts', '*.vue', '**/*.vue'],
|
|
16
18
|
}
|
|
19
|
+
}),
|
|
20
|
+
{
|
|
21
|
+
files: ['*.ts', '**/*.ts', '*.vue', '**/*.vue'],
|
|
22
|
+
languageOptions: {
|
|
23
|
+
sourceType: 'module',
|
|
24
|
+
parser: pluginVue.parser,
|
|
25
|
+
parserOptions: {
|
|
26
|
+
parser: tseslint.parser,
|
|
27
|
+
projectService: true,
|
|
28
|
+
extraFileExtensions: ['.vue'],
|
|
29
|
+
logConfigResolution: true, // logs which tsconfig is used per file
|
|
30
|
+
},
|
|
31
|
+
},
|
|
17
32
|
},
|
|
18
33
|
{
|
|
19
|
-
|
|
34
|
+
files: ['*.ts', '**/*.ts', '*.vue', '**/*.vue'],
|
|
20
35
|
rules: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"vue/component-tags-order": [
|
|
28
|
-
"error",
|
|
36
|
+
'vue/html-indent': ['warn', 4],
|
|
37
|
+
'vue/html-button-has-type': 'error',
|
|
38
|
+
'vue/no-mutating-props': 'off',
|
|
39
|
+
'vue/max-attributes-per-line': 'off',
|
|
40
|
+
'vue/block-order': [
|
|
41
|
+
'error',
|
|
29
42
|
{
|
|
30
|
-
order: [
|
|
43
|
+
order: ['template', 'script', 'style'],
|
|
31
44
|
},
|
|
32
45
|
],
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
]
|
|
46
|
+
'vue/no-unused-components': 'warn',
|
|
47
|
+
'vue/no-multiple-template-root': 'off', // For some reason when you have html comments inside components, they are treated as root elements too, which cause unwanted bugs
|
|
48
|
+
'vue/multi-word-component-names': 'off',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
];
|
package/src/configs/node.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import nodePlugin from 'eslint-plugin-n';
|
|
2
|
+
import globals from 'globals';
|
|
3
3
|
|
|
4
4
|
export default [
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
globals: {
|
|
8
|
+
...globals.node,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
5
12
|
{
|
|
6
13
|
plugins: {
|
|
7
|
-
n: nodePlugin
|
|
14
|
+
n: nodePlugin,
|
|
8
15
|
},
|
|
9
16
|
rules: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
+
'n/file-extension-in-import': [
|
|
18
|
+
'error',
|
|
19
|
+
'always',
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
files: ['**/*.d.ts'],
|
|
25
|
+
rules: {
|
|
26
|
+
'n/file-extension-in-import': 'off',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export default {
|
|
4
2
|
rules: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
'no-undef': 'off', // Does not work with TypeScript
|
|
4
|
+
|
|
5
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
6
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
'no-unused-vars': 'off',
|
|
9
|
+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', caughtErrors: 'none' }],
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
'prefer-promise-reject-errors': 'off',
|
|
12
|
+
'@typescript-eslint/prefer-promise-reject-errors': 'off', // Does not work correctly when passing on 'any' errors in a try catch block using reject()
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
'@typescript-eslint/no-namespace': 'off',
|
|
15
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
16
|
+
'@typescript-eslint/no-misused-promises': 'error',
|
|
17
|
+
'@typescript-eslint/prefer-for-of': 'warn',
|
|
18
|
+
'@typescript-eslint/no-empty-interface': 'off', // It is convenient to have placeholder interfaces
|
|
19
|
+
'@typescript-eslint/no-this-alias': 'off', // No idea why we need this. This breaks code that is just fine. Prohibit the use of function() instead of this rule
|
|
20
|
+
'@typescript-eslint/unbound-method': 'off', // Methods are automatically bound in vue, it would break removeEventListeners if we bound it every time unless we save every method in variables again...
|
|
21
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'off', // There is a bug in the autofix that breaks Vue code (it changes code on the wrong position)
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off', // Don't need this, since we don't export methods, and is annoying for async methods without return values
|
|
23
|
+
|
|
24
|
+
'@typescript-eslint/no-unsafe-assignment': 'off', // This is impossible to use with dependencies that don't have types yet, such as tiptap
|
|
25
|
+
'@typescript-eslint/no-unsafe-return': 'off', // This is impossible to use with dependencies that don't have types yet, such as tiptap
|
|
26
|
+
'@typescript-eslint/no-unsafe-call': 'off', // This is impossible to use with dependencies that don't have types yet, such as tiptap
|
|
27
|
+
'@typescript-eslint/no-unsafe-member-access': 'off', // This is impossible to use with dependencies that don't have types yet, such as tiptap
|
|
28
|
+
'@typescript-eslint/restrict-plus-operands': 'off', // bullshit one
|
|
29
|
+
'@typescript-eslint/require-await': 'off', // You should be able to define async methods if you need to match required interfaces or types
|
|
30
|
+
|
|
31
|
+
'@typescript-eslint/no-redundant-type-constituents': 'off', // Weird behaviour and reduces code readability
|
|
32
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
33
|
+
|
|
34
|
+
// Make sure imports that are only used as a type are transferred into type imports
|
|
35
|
+
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
25
36
|
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"@typescript-eslint/restrict-plus-operands": "off", // bullshit one
|
|
31
|
-
"@typescript-eslint/require-await": "off", // You should be able to define async methods if you need to match required interfaces or types
|
|
32
|
-
|
|
33
|
-
"@typescript-eslint/no-redundant-type-constituents": "off", // Weird behaviour and reduces code readability
|
|
34
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
+
// TypeScript leaves in "import {type Test} from './test.ts'" as "import {} from './test.ts'", while it removes "import type {Test} from './test.ts'" when verbatimModuleSyntax is enabled. To avoid not removing it, we prefer top level
|
|
38
|
+
'import/consistent-type-specifier-style': ['warn', 'prefer-top-level'],
|
|
39
|
+
},
|
|
40
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,69 +1,65 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
import tseslint from 'typescript-eslint';
|
|
3
2
|
import eslint from '@eslint/js';
|
|
4
|
-
import stylistic from '@stylistic/eslint-plugin'
|
|
3
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
5
4
|
import importPlugin from 'eslint-plugin-import';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
6
|
|
|
7
7
|
// Configs
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import vitest from '@vitest/eslint-plugin';
|
|
9
|
+
import regexpPlugin from 'eslint-plugin-regexp';
|
|
10
10
|
import defaultRules from './configs/default.js';
|
|
11
|
-
import
|
|
11
|
+
import frontend from './configs/frontend.js';
|
|
12
12
|
import node from './configs/node.js';
|
|
13
|
-
import
|
|
13
|
+
import typescript from './configs/typescript.js';
|
|
14
14
|
|
|
15
15
|
const baseRules = [
|
|
16
|
+
...defaultRules,
|
|
17
|
+
regexpPlugin.configs.recommended,
|
|
16
18
|
{
|
|
17
19
|
settings: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
'import/parsers': {
|
|
21
|
+
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
20
22
|
},
|
|
21
23
|
'import/resolver': {
|
|
22
24
|
typescript: {
|
|
23
|
-
bun: false
|
|
25
|
+
bun: false,
|
|
24
26
|
},
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
},
|
|
28
30
|
eslint.configs.recommended,
|
|
29
|
-
...tseslint.configs.recommendedTypeChecked
|
|
31
|
+
...tseslint.configs.recommendedTypeChecked.map(config => ({
|
|
32
|
+
...config,
|
|
33
|
+
files: ['*.ts', '**/*.ts', '*.vue', '**/*.vue'], // We use TS config only for TS files
|
|
34
|
+
})),
|
|
30
35
|
{
|
|
31
|
-
|
|
32
|
-
'import': importPlugin
|
|
33
|
-
},
|
|
34
|
-
rules: {
|
|
35
|
-
"import/no-unresolved": "error",
|
|
36
|
-
'import/no-cycle': ["warn", { maxDepth: 100, ignoreExternal: false }],
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
stylistic.configs.customize({
|
|
40
|
-
// the following options are the default values
|
|
41
|
-
indent: 4,
|
|
42
|
-
quotes: 'single',
|
|
43
|
-
semi: true,
|
|
44
|
-
jsx: false
|
|
45
|
-
}),
|
|
46
|
-
{
|
|
47
|
-
rules: {
|
|
48
|
-
'@stylistic/quotes': ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }],
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
// Make sure TypeScript type checking can run correctly for rules that require it
|
|
53
|
-
files: ['*.ts', '**/*.ts'],
|
|
36
|
+
files: ['*.ts', '**/*.ts', '*.vue', '**/*.vue'],
|
|
54
37
|
languageOptions: {
|
|
38
|
+
sourceType: 'module',
|
|
39
|
+
parser: tseslint.parser,
|
|
55
40
|
parserOptions: {
|
|
56
41
|
projectService: true,
|
|
57
|
-
tsconfigRootDir: import.meta.dirname,
|
|
58
42
|
},
|
|
59
|
-
}
|
|
60
|
-
|
|
43
|
+
},
|
|
44
|
+
...typescript,
|
|
45
|
+
},
|
|
61
46
|
{
|
|
62
|
-
|
|
47
|
+
plugins: {
|
|
48
|
+
import: importPlugin,
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
'import/no-cycle': ['warn', { maxDepth: 100, ignoreExternal: false }],
|
|
52
|
+
},
|
|
63
53
|
},
|
|
64
54
|
{
|
|
65
|
-
files: ['
|
|
66
|
-
|
|
55
|
+
files: ['**/*.js', '**/*.ts'],
|
|
56
|
+
plugins: {
|
|
57
|
+
'@stylistic': stylistic,
|
|
58
|
+
},
|
|
59
|
+
rules: {
|
|
60
|
+
...stylistic.configs.recommended,
|
|
61
|
+
'@stylistic/quotes': ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }],
|
|
62
|
+
},
|
|
67
63
|
},
|
|
68
64
|
{
|
|
69
65
|
// Make sure we disable TypeScript eslint rules that are not compatible with JavaScript files
|
|
@@ -73,20 +69,32 @@ const baseRules = [
|
|
|
73
69
|
{
|
|
74
70
|
files: ['**/*.cjs'],
|
|
75
71
|
languageOptions: {
|
|
76
|
-
sourceType:
|
|
77
|
-
}
|
|
72
|
+
sourceType: 'commonjs',
|
|
73
|
+
},
|
|
78
74
|
},
|
|
79
75
|
{
|
|
80
|
-
files: ['**/*.test.js', '**/*.test.ts'],
|
|
81
|
-
|
|
76
|
+
files: ['tests/**', '**/*.test.js', '**/*.test.ts'],
|
|
77
|
+
plugins: { vitest },
|
|
82
78
|
rules: {
|
|
83
|
-
...
|
|
84
|
-
'
|
|
79
|
+
...vitest.configs.recommended.rules,
|
|
80
|
+
'vitest/no-conditional-expect': 'warn',
|
|
81
|
+
'vitest/expect-expect': 'warn',
|
|
82
|
+
'vitest/valid-expect': ['warn', {maxArgs: 2}] // Allow to pass a message by variable
|
|
85
83
|
},
|
|
86
84
|
},
|
|
87
85
|
|
|
88
86
|
{
|
|
89
|
-
ignores: [
|
|
87
|
+
ignores: ['**/dist/*', '**/dist-*/*', '**/ios/*', '**/android/*'],
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
{
|
|
91
|
+
// https://github.com/vitest-dev/vitest/issues/4543#issuecomment-1824628142
|
|
92
|
+
files: ['**/*.test.js', '**/*.test.ts'],
|
|
93
|
+
rules: {
|
|
94
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
95
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
96
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
97
|
+
},
|
|
90
98
|
}
|
|
91
99
|
];
|
|
92
100
|
|
|
@@ -95,22 +103,15 @@ export default {
|
|
|
95
103
|
base: baseRules,
|
|
96
104
|
frontend: [
|
|
97
105
|
...baseRules,
|
|
98
|
-
...frontend
|
|
106
|
+
...frontend,
|
|
99
107
|
],
|
|
100
108
|
backend: [
|
|
101
|
-
{
|
|
102
|
-
languageOptions: {
|
|
103
|
-
globals: {
|
|
104
|
-
...globals.node,
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
109
|
...baseRules,
|
|
109
|
-
...node
|
|
110
|
+
...node,
|
|
110
111
|
],
|
|
111
112
|
shared: [
|
|
112
113
|
...baseRules,
|
|
113
|
-
...node
|
|
114
|
-
]
|
|
114
|
+
...node,
|
|
115
|
+
],
|
|
115
116
|
},
|
|
116
117
|
};
|