@itstandu/code-style 0.1.0 → 0.1.2
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/README.md +13 -39
- package/eslint/angular.js +7 -7
- package/eslint/base.js +39 -18
- package/eslint/javascript.js +15 -1
- package/eslint/nest.js +15 -2
- package/eslint/next.js +27 -5
- package/eslint/node.js +33 -3
- package/eslint/react.js +9 -9
- package/eslint/recommended.js +21 -2
- package/eslint/strict.js +20 -3
- package/eslint/typescript.js +40 -6
- package/eslint/vue.js +8 -8
- package/index.js +1 -1
- package/package.json +24 -24
- package/prettier/index.cjs +24 -6
package/README.md
CHANGED
|
@@ -59,11 +59,7 @@ Create `eslint.config.js` (or `eslint.config.mjs`) in your project root:
|
|
|
59
59
|
```javascript
|
|
60
60
|
const codeStyle = require('@itstandu/code-style')
|
|
61
61
|
|
|
62
|
-
module.exports = [
|
|
63
|
-
codeStyle.base,
|
|
64
|
-
codeStyle.typescript,
|
|
65
|
-
codeStyle.node
|
|
66
|
-
]
|
|
62
|
+
module.exports = [codeStyle.base, codeStyle.typescript, codeStyle.node]
|
|
67
63
|
```
|
|
68
64
|
|
|
69
65
|
#### Recommended Preset (Better Safety)
|
|
@@ -71,11 +67,7 @@ module.exports = [
|
|
|
71
67
|
```javascript
|
|
72
68
|
const codeStyle = require('@itstandu/code-style')
|
|
73
69
|
|
|
74
|
-
module.exports = [
|
|
75
|
-
codeStyle.recommended,
|
|
76
|
-
codeStyle.typescript,
|
|
77
|
-
codeStyle.node
|
|
78
|
-
]
|
|
70
|
+
module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.node]
|
|
79
71
|
```
|
|
80
72
|
|
|
81
73
|
#### Strict Preset (Opt-in, includes boundaries)
|
|
@@ -83,11 +75,7 @@ module.exports = [
|
|
|
83
75
|
```javascript
|
|
84
76
|
const codeStyle = require('@itstandu/code-style')
|
|
85
77
|
|
|
86
|
-
module.exports = [
|
|
87
|
-
codeStyle.strict,
|
|
88
|
-
codeStyle.typescript,
|
|
89
|
-
codeStyle.node
|
|
90
|
-
]
|
|
78
|
+
module.exports = [codeStyle.strict, codeStyle.typescript, codeStyle.node]
|
|
91
79
|
```
|
|
92
80
|
|
|
93
81
|
### Framework Presets
|
|
@@ -97,11 +85,7 @@ module.exports = [
|
|
|
97
85
|
```javascript
|
|
98
86
|
const codeStyle = require('@itstandu/code-style')
|
|
99
87
|
|
|
100
|
-
module.exports = [
|
|
101
|
-
codeStyle.recommended,
|
|
102
|
-
codeStyle.typescript,
|
|
103
|
-
codeStyle.react
|
|
104
|
-
]
|
|
88
|
+
module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.react]
|
|
105
89
|
```
|
|
106
90
|
|
|
107
91
|
#### Next.js
|
|
@@ -109,11 +93,7 @@ module.exports = [
|
|
|
109
93
|
```javascript
|
|
110
94
|
const codeStyle = require('@itstandu/code-style')
|
|
111
95
|
|
|
112
|
-
module.exports = [
|
|
113
|
-
codeStyle.recommended,
|
|
114
|
-
codeStyle.typescript,
|
|
115
|
-
codeStyle.next
|
|
116
|
-
]
|
|
96
|
+
module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.next]
|
|
117
97
|
```
|
|
118
98
|
|
|
119
99
|
#### Vue
|
|
@@ -121,10 +101,7 @@ module.exports = [
|
|
|
121
101
|
```javascript
|
|
122
102
|
const codeStyle = require('@itstandu/code-style')
|
|
123
103
|
|
|
124
|
-
module.exports = [
|
|
125
|
-
codeStyle.recommended,
|
|
126
|
-
codeStyle.vue
|
|
127
|
-
]
|
|
104
|
+
module.exports = [codeStyle.recommended, codeStyle.vue]
|
|
128
105
|
```
|
|
129
106
|
|
|
130
107
|
#### Angular
|
|
@@ -132,11 +109,7 @@ module.exports = [
|
|
|
132
109
|
```javascript
|
|
133
110
|
const codeStyle = require('@itstandu/code-style')
|
|
134
111
|
|
|
135
|
-
module.exports = [
|
|
136
|
-
codeStyle.recommended,
|
|
137
|
-
codeStyle.typescript,
|
|
138
|
-
codeStyle.angular
|
|
139
|
-
]
|
|
112
|
+
module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.angular]
|
|
140
113
|
```
|
|
141
114
|
|
|
142
115
|
#### NestJS
|
|
@@ -144,11 +117,7 @@ module.exports = [
|
|
|
144
117
|
```javascript
|
|
145
118
|
const codeStyle = require('@itstandu/code-style')
|
|
146
119
|
|
|
147
|
-
module.exports = [
|
|
148
|
-
codeStyle.recommended,
|
|
149
|
-
codeStyle.typescript,
|
|
150
|
-
codeStyle.nest
|
|
151
|
-
]
|
|
120
|
+
module.exports = [codeStyle.recommended, codeStyle.typescript, codeStyle.nest]
|
|
152
121
|
```
|
|
153
122
|
|
|
154
123
|
### Prettier
|
|
@@ -204,19 +173,24 @@ This package ensures **100% Prettier coverage** for all formatting:
|
|
|
204
173
|
**Result:** Clean separation of concerns, no conflicts, battle-tested approach.
|
|
205
174
|
|
|
206
175
|
**Important:** Make sure your editor/IDE:
|
|
176
|
+
|
|
207
177
|
- Uses Prettier as default formatter with `formatOnSave`
|
|
208
178
|
- Runs ESLint auto-fix on save (`source.fixAll.eslint`) for import sorting
|
|
209
179
|
|
|
210
180
|
## Presets
|
|
211
181
|
|
|
212
182
|
### `base`
|
|
183
|
+
|
|
213
184
|
Minimal, safe defaults. Good starting point.
|
|
214
185
|
|
|
215
186
|
### `recommended`
|
|
187
|
+
|
|
216
188
|
Enhanced safety rules while remaining practical. Recommended for most projects.
|
|
217
189
|
|
|
218
190
|
### `strict`
|
|
191
|
+
|
|
219
192
|
Opt-in preset with additional rules including:
|
|
193
|
+
|
|
220
194
|
- `eslint-plugin-unicorn` (code quality)
|
|
221
195
|
- `eslint-plugin-sonarjs` (bug detection)
|
|
222
196
|
- `eslint-plugin-boundaries` (architecture enforcement, disabled by default)
|
package/eslint/angular.js
CHANGED
|
@@ -5,7 +5,7 @@ module.exports = {
|
|
|
5
5
|
plugins: {
|
|
6
6
|
...ts.plugins,
|
|
7
7
|
'@angular-eslint': require('@angular-eslint/eslint-plugin'),
|
|
8
|
-
'@angular-eslint/template': require('@angular-eslint/eslint-plugin-template')
|
|
8
|
+
'@angular-eslint/template': require('@angular-eslint/eslint-plugin-template'),
|
|
9
9
|
},
|
|
10
10
|
rules: {
|
|
11
11
|
...ts.rules,
|
|
@@ -14,16 +14,16 @@ module.exports = {
|
|
|
14
14
|
{
|
|
15
15
|
type: 'attribute',
|
|
16
16
|
prefix: 'app',
|
|
17
|
-
style: 'camelCase'
|
|
18
|
-
}
|
|
17
|
+
style: 'camelCase',
|
|
18
|
+
},
|
|
19
19
|
],
|
|
20
20
|
'@angular-eslint/component-selector': [
|
|
21
21
|
'warn',
|
|
22
22
|
{
|
|
23
23
|
type: 'element',
|
|
24
24
|
prefix: 'app',
|
|
25
|
-
style: 'kebab-case'
|
|
26
|
-
}
|
|
25
|
+
style: 'kebab-case',
|
|
26
|
+
},
|
|
27
27
|
],
|
|
28
28
|
'@angular-eslint/no-empty-lifecycle-method': 'warn',
|
|
29
29
|
'@angular-eslint/no-host-metadata-property': 'warn',
|
|
@@ -31,6 +31,6 @@ module.exports = {
|
|
|
31
31
|
'@angular-eslint/no-output-on-prefix': 'warn',
|
|
32
32
|
'@angular-eslint/no-output-rename': 'warn',
|
|
33
33
|
'@angular-eslint/use-lifecycle-interface': 'warn',
|
|
34
|
-
'@angular-eslint/use-pipe-transform-interface': 'warn'
|
|
35
|
-
}
|
|
34
|
+
'@angular-eslint/use-pipe-transform-interface': 'warn',
|
|
35
|
+
},
|
|
36
36
|
}
|
package/eslint/base.js
CHANGED
|
@@ -9,65 +9,86 @@ module.exports = {
|
|
|
9
9
|
'**/.output/**',
|
|
10
10
|
'**/.turbo/**',
|
|
11
11
|
'**/.cache/**',
|
|
12
|
-
'**/coverage/**'
|
|
12
|
+
'**/coverage/**',
|
|
13
13
|
],
|
|
14
14
|
languageOptions: {
|
|
15
15
|
ecmaVersion: 'latest',
|
|
16
16
|
sourceType: 'module',
|
|
17
|
-
globals: {}
|
|
17
|
+
globals: {},
|
|
18
18
|
},
|
|
19
19
|
plugins: {
|
|
20
20
|
'simple-import-sort': require('eslint-plugin-simple-import-sort'),
|
|
21
21
|
'unused-imports': require('eslint-plugin-unused-imports'),
|
|
22
|
-
import: require('eslint-plugin-import')
|
|
22
|
+
import: require('eslint-plugin-import'),
|
|
23
23
|
},
|
|
24
24
|
settings: {
|
|
25
25
|
'import/resolver': {
|
|
26
26
|
node: {
|
|
27
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs']
|
|
27
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'],
|
|
28
28
|
},
|
|
29
29
|
typescript: {
|
|
30
|
-
alwaysTryTypes: true
|
|
31
|
-
}
|
|
32
|
-
}
|
|
30
|
+
alwaysTryTypes: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
33
|
},
|
|
34
34
|
rules: {
|
|
35
35
|
...prettierConfig.rules,
|
|
36
36
|
|
|
37
|
+
// Error prevention
|
|
37
38
|
'no-undef': 'error',
|
|
38
39
|
'no-unreachable': 'error',
|
|
39
40
|
'no-duplicate-imports': 'error',
|
|
40
41
|
'no-console': 'warn',
|
|
41
42
|
|
|
43
|
+
// Best practices
|
|
42
44
|
'no-var': 'error',
|
|
43
45
|
'prefer-const': 'error',
|
|
44
46
|
'no-shadow': 'off',
|
|
47
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
48
|
+
curly: ['error', 'multi-line', 'consistent'],
|
|
45
49
|
|
|
50
|
+
// Control flow
|
|
46
51
|
'no-fallthrough': 'error',
|
|
47
52
|
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
48
53
|
|
|
54
|
+
// Async
|
|
49
55
|
'no-async-promise-executor': 'error',
|
|
56
|
+
'no-return-await': 'warn',
|
|
57
|
+
'require-await': 'off',
|
|
50
58
|
|
|
59
|
+
// Import sorting
|
|
51
60
|
'simple-import-sort/imports': [
|
|
52
61
|
'error',
|
|
53
62
|
{
|
|
54
|
-
groups: [
|
|
55
|
-
|
|
56
|
-
['^node:'],
|
|
57
|
-
['^@?\\w'],
|
|
58
|
-
['^@/'],
|
|
59
|
-
['^\\.\\.'],
|
|
60
|
-
['^\\.']
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
+
groups: [['^\\u0000'], ['^node:'], ['^@?\\w'], ['^@/'], ['^\\.\\.'], ['^\\.']],
|
|
64
|
+
},
|
|
63
65
|
],
|
|
64
66
|
'simple-import-sort/exports': 'error',
|
|
65
67
|
|
|
68
|
+
// Unused imports - must use plugin for auto-fix
|
|
69
|
+
// STRICT: No underscore bypass - use `void variable` for intentionally unused
|
|
66
70
|
'unused-imports/no-unused-imports': 'error',
|
|
71
|
+
'unused-imports/no-unused-vars': [
|
|
72
|
+
'error',
|
|
73
|
+
{
|
|
74
|
+
vars: 'all',
|
|
75
|
+
args: 'after-used',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
67
78
|
'no-unused-vars': 'off',
|
|
68
79
|
|
|
80
|
+
// STRICT: No eslint-disable comments allowed
|
|
81
|
+
'no-warning-comments': [
|
|
82
|
+
'error',
|
|
83
|
+
{
|
|
84
|
+
terms: ['eslint-disable', 'eslint-disable-line', 'eslint-disable-next-line'],
|
|
85
|
+
location: 'anywhere',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
|
|
89
|
+
// Import plugin
|
|
69
90
|
'import/first': 'error',
|
|
70
91
|
'import/newline-after-import': 'error',
|
|
71
|
-
'import/no-duplicates': 'error'
|
|
72
|
-
}
|
|
92
|
+
'import/no-duplicates': 'error',
|
|
93
|
+
},
|
|
73
94
|
}
|
package/eslint/javascript.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
const base = require('./base')
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
...base
|
|
4
|
+
...base,
|
|
5
|
+
languageOptions: {
|
|
6
|
+
...base.languageOptions,
|
|
7
|
+
parserOptions: {
|
|
8
|
+
ecmaVersion: 'latest',
|
|
9
|
+
sourceType: 'module',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
...base.rules,
|
|
14
|
+
|
|
15
|
+
// JS inherits strict unused-vars from base
|
|
16
|
+
// STRICT: No underscore bypass - use `void variable` for intentionally unused
|
|
17
|
+
'no-unused-vars': 'off',
|
|
18
|
+
},
|
|
5
19
|
}
|
package/eslint/nest.js
CHANGED
|
@@ -4,9 +4,22 @@ module.exports = {
|
|
|
4
4
|
...node,
|
|
5
5
|
rules: {
|
|
6
6
|
...node.rules,
|
|
7
|
+
|
|
8
|
+
// NestJS uses decorators and DI heavily
|
|
7
9
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
8
10
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
9
11
|
'@typescript-eslint/interface-name-prefix': 'off',
|
|
10
|
-
'@typescript-eslint/naming-convention': 'off'
|
|
11
|
-
|
|
12
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
13
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
14
|
+
|
|
15
|
+
// NestJS uses empty constructors for DI
|
|
16
|
+
'no-useless-constructor': 'off',
|
|
17
|
+
'@typescript-eslint/no-useless-constructor': 'off',
|
|
18
|
+
|
|
19
|
+
// NestJS uses parameter properties
|
|
20
|
+
'@typescript-eslint/parameter-properties': 'off',
|
|
21
|
+
|
|
22
|
+
// Allow any for DTOs and decorators
|
|
23
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
|
+
},
|
|
12
25
|
}
|
package/eslint/next.js
CHANGED
|
@@ -2,9 +2,31 @@ const react = require('./react')
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
...react,
|
|
5
|
-
ignores: [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'
|
|
9
|
-
|
|
5
|
+
ignores: [...react.ignores, '**/.next/**', '**/out/**', '**/.vercel/**'],
|
|
6
|
+
settings: {
|
|
7
|
+
...react.settings,
|
|
8
|
+
// Next.js uses React 18+ which doesn't need React import
|
|
9
|
+
react: {
|
|
10
|
+
version: 'detect',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
...react.rules,
|
|
15
|
+
|
|
16
|
+
// Next.js specific - allow img for optimization bypass cases
|
|
17
|
+
'@next/next/no-img-element': 'off',
|
|
18
|
+
|
|
19
|
+
// Allow anchor without href for Link component children
|
|
20
|
+
'jsx-a11y/anchor-is-valid': [
|
|
21
|
+
'warn',
|
|
22
|
+
{
|
|
23
|
+
components: ['Link'],
|
|
24
|
+
specialLink: ['hrefLeft', 'hrefRight'],
|
|
25
|
+
aspects: ['invalidHref', 'preferButton'],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
|
|
29
|
+
// Next.js handles these automatically
|
|
30
|
+
'react/react-in-jsx-scope': 'off',
|
|
31
|
+
},
|
|
10
32
|
}
|
package/eslint/node.js
CHANGED
|
@@ -2,17 +2,47 @@ const ts = require('./typescript')
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
...ts,
|
|
5
|
+
languageOptions: {
|
|
6
|
+
...ts.languageOptions,
|
|
7
|
+
globals: {
|
|
8
|
+
...ts.languageOptions.globals,
|
|
9
|
+
// Node.js global variables
|
|
10
|
+
__dirname: 'readonly',
|
|
11
|
+
__filename: 'readonly',
|
|
12
|
+
Buffer: 'readonly',
|
|
13
|
+
process: 'readonly',
|
|
14
|
+
console: 'readonly',
|
|
15
|
+
module: 'readonly',
|
|
16
|
+
require: 'readonly',
|
|
17
|
+
exports: 'writable',
|
|
18
|
+
global: 'readonly',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
5
21
|
plugins: {
|
|
6
22
|
...ts.plugins,
|
|
7
23
|
promise: require('eslint-plugin-promise'),
|
|
8
|
-
n: require('eslint-plugin-n')
|
|
24
|
+
n: require('eslint-plugin-n'),
|
|
9
25
|
},
|
|
10
26
|
rules: {
|
|
11
27
|
...ts.rules,
|
|
28
|
+
|
|
29
|
+
// Node.js specific
|
|
12
30
|
'n/no-process-exit': 'off',
|
|
13
31
|
'n/no-missing-import': 'off',
|
|
32
|
+
'n/no-unsupported-features/es-syntax': 'off',
|
|
33
|
+
'n/no-unpublished-import': 'off',
|
|
34
|
+
'n/no-extraneous-import': 'off',
|
|
35
|
+
'n/prefer-global/buffer': ['warn', 'always'],
|
|
36
|
+
'n/prefer-global/process': ['warn', 'always'],
|
|
37
|
+
'n/prefer-promises/fs': 'warn',
|
|
38
|
+
'n/prefer-promises/dns': 'warn',
|
|
39
|
+
|
|
40
|
+
// Promise best practices
|
|
14
41
|
'promise/always-return': 'off',
|
|
15
42
|
'promise/no-nesting': 'off',
|
|
16
|
-
'promise/no-callback-in-promise': 'warn'
|
|
17
|
-
|
|
43
|
+
'promise/no-callback-in-promise': 'warn',
|
|
44
|
+
'promise/catch-or-return': 'off',
|
|
45
|
+
'promise/no-return-wrap': 'error',
|
|
46
|
+
'promise/param-names': 'error',
|
|
47
|
+
},
|
|
18
48
|
}
|
package/eslint/react.js
CHANGED
|
@@ -7,25 +7,25 @@ module.exports = {
|
|
|
7
7
|
parserOptions: {
|
|
8
8
|
...ts.languageOptions.parserOptions,
|
|
9
9
|
ecmaFeatures: {
|
|
10
|
-
jsx: true
|
|
11
|
-
}
|
|
10
|
+
jsx: true,
|
|
11
|
+
},
|
|
12
12
|
},
|
|
13
13
|
globals: {
|
|
14
14
|
...ts.languageOptions.globals,
|
|
15
15
|
React: 'readonly',
|
|
16
|
-
JSX: 'readonly'
|
|
17
|
-
}
|
|
16
|
+
JSX: 'readonly',
|
|
17
|
+
},
|
|
18
18
|
},
|
|
19
19
|
plugins: {
|
|
20
20
|
...ts.plugins,
|
|
21
21
|
react: require('eslint-plugin-react'),
|
|
22
22
|
'react-hooks': require('eslint-plugin-react-hooks'),
|
|
23
|
-
'jsx-a11y': require('eslint-plugin-jsx-a11y')
|
|
23
|
+
'jsx-a11y': require('eslint-plugin-jsx-a11y'),
|
|
24
24
|
},
|
|
25
25
|
settings: {
|
|
26
26
|
react: {
|
|
27
|
-
version: 'detect'
|
|
28
|
-
}
|
|
27
|
+
version: 'detect',
|
|
28
|
+
},
|
|
29
29
|
},
|
|
30
30
|
rules: {
|
|
31
31
|
...ts.rules,
|
|
@@ -96,6 +96,6 @@ module.exports = {
|
|
|
96
96
|
'jsx-a11y/role-has-required-aria-props': 'warn',
|
|
97
97
|
'jsx-a11y/role-supports-aria-props': 'warn',
|
|
98
98
|
'jsx-a11y/scope': 'warn',
|
|
99
|
-
'jsx-a11y/tabindex-no-positive': 'warn'
|
|
100
|
-
}
|
|
99
|
+
'jsx-a11y/tabindex-no-positive': 'warn',
|
|
100
|
+
},
|
|
101
101
|
}
|
package/eslint/recommended.js
CHANGED
|
@@ -4,26 +4,45 @@ module.exports = {
|
|
|
4
4
|
...base,
|
|
5
5
|
rules: {
|
|
6
6
|
...base.rules,
|
|
7
|
+
|
|
8
|
+
// Console and debugging
|
|
7
9
|
'no-console': 'warn',
|
|
8
10
|
'no-debugger': 'error',
|
|
9
11
|
'no-alert': 'warn',
|
|
12
|
+
|
|
13
|
+
// Security
|
|
10
14
|
'no-eval': 'error',
|
|
11
15
|
'no-implied-eval': 'error',
|
|
12
16
|
'no-new-func': 'error',
|
|
13
17
|
'no-script-url': 'error',
|
|
14
18
|
|
|
19
|
+
// Modern JavaScript
|
|
15
20
|
'prefer-arrow-callback': 'warn',
|
|
16
21
|
'prefer-template': 'warn',
|
|
17
22
|
'prefer-spread': 'warn',
|
|
18
23
|
'prefer-rest-params': 'warn',
|
|
24
|
+
'prefer-destructuring': [
|
|
25
|
+
'warn',
|
|
26
|
+
{
|
|
27
|
+
array: false,
|
|
28
|
+
object: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
'object-shorthand': ['warn', 'always'],
|
|
19
32
|
|
|
33
|
+
// Code cleanliness
|
|
20
34
|
'no-useless-return': 'warn',
|
|
21
35
|
'no-useless-concat': 'warn',
|
|
22
36
|
'no-useless-escape': 'warn',
|
|
37
|
+
'no-useless-rename': 'warn',
|
|
38
|
+
'no-lonely-if': 'warn',
|
|
39
|
+
'no-unneeded-ternary': 'warn',
|
|
23
40
|
|
|
41
|
+
// Import hygiene
|
|
24
42
|
'import/no-unresolved': 'off',
|
|
25
43
|
'import/no-cycle': 'warn',
|
|
26
44
|
'import/no-self-import': 'error',
|
|
27
|
-
'import/no-useless-path-segments': 'error'
|
|
28
|
-
|
|
45
|
+
'import/no-useless-path-segments': 'error',
|
|
46
|
+
'import/no-mutable-exports': 'error',
|
|
47
|
+
},
|
|
29
48
|
}
|
package/eslint/strict.js
CHANGED
|
@@ -6,11 +6,12 @@ module.exports = {
|
|
|
6
6
|
...recommended.plugins,
|
|
7
7
|
boundaries: require('eslint-plugin-boundaries'),
|
|
8
8
|
unicorn: require('eslint-plugin-unicorn'),
|
|
9
|
-
sonarjs: require('eslint-plugin-sonarjs')
|
|
9
|
+
sonarjs: require('eslint-plugin-sonarjs'),
|
|
10
10
|
},
|
|
11
11
|
rules: {
|
|
12
12
|
...recommended.rules,
|
|
13
13
|
|
|
14
|
+
// Unicorn - modern JavaScript best practices
|
|
14
15
|
'unicorn/prefer-module': 'off',
|
|
15
16
|
'unicorn/prefer-node-protocol': 'warn',
|
|
16
17
|
'unicorn/no-array-callback-reference': 'warn',
|
|
@@ -21,15 +22,31 @@ module.exports = {
|
|
|
21
22
|
'unicorn/prefer-string-slice': 'warn',
|
|
22
23
|
'unicorn/no-useless-undefined': 'warn',
|
|
23
24
|
'unicorn/prefer-optional-catch-binding': 'warn',
|
|
25
|
+
'unicorn/no-null': 'off',
|
|
26
|
+
'unicorn/filename-case': 'off',
|
|
27
|
+
'unicorn/prevent-abbreviations': 'off',
|
|
28
|
+
'unicorn/no-array-reduce': 'off',
|
|
29
|
+
'unicorn/no-array-for-each': 'off',
|
|
30
|
+
'unicorn/prefer-spread': 'off',
|
|
31
|
+
'unicorn/prefer-ternary': 'off',
|
|
32
|
+
'unicorn/consistent-function-scoping': 'warn',
|
|
33
|
+
'unicorn/no-lonely-if': 'warn',
|
|
34
|
+
'unicorn/prefer-number-properties': 'warn',
|
|
35
|
+
'unicorn/prefer-date-now': 'warn',
|
|
24
36
|
|
|
37
|
+
// SonarJS - bug detection
|
|
25
38
|
'sonarjs/cognitive-complexity': 'off',
|
|
26
39
|
'sonarjs/no-duplicate-string': 'off',
|
|
27
40
|
'sonarjs/no-small-switch': 'off',
|
|
28
41
|
'sonarjs/prefer-immediate-return': 'warn',
|
|
29
42
|
'sonarjs/prefer-single-boolean-return': 'warn',
|
|
43
|
+
'sonarjs/no-identical-functions': 'warn',
|
|
44
|
+
'sonarjs/no-collapsible-if': 'warn',
|
|
45
|
+
'sonarjs/no-redundant-jump': 'warn',
|
|
30
46
|
|
|
47
|
+
// Boundaries - architecture enforcement (opt-in, disabled by default)
|
|
31
48
|
'boundaries/element-types': 'off',
|
|
32
49
|
'boundaries/no-private': 'off',
|
|
33
|
-
'boundaries/entry-point': 'off'
|
|
34
|
-
}
|
|
50
|
+
'boundaries/entry-point': 'off',
|
|
51
|
+
},
|
|
35
52
|
}
|
package/eslint/typescript.js
CHANGED
|
@@ -9,28 +9,62 @@ module.exports = {
|
|
|
9
9
|
ecmaVersion: 'latest',
|
|
10
10
|
sourceType: 'module',
|
|
11
11
|
project: true,
|
|
12
|
-
tsconfigRootDir: process.cwd()
|
|
13
|
-
}
|
|
12
|
+
tsconfigRootDir: process.cwd(),
|
|
13
|
+
},
|
|
14
14
|
},
|
|
15
15
|
plugins: {
|
|
16
16
|
...base.plugins,
|
|
17
|
-
'@typescript-eslint': require('@typescript-eslint/eslint-plugin')
|
|
17
|
+
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
|
|
18
18
|
},
|
|
19
19
|
rules: {
|
|
20
20
|
...base.rules,
|
|
21
|
+
|
|
22
|
+
// Disable base rules that TypeScript handles
|
|
21
23
|
'no-unused-vars': 'off',
|
|
24
|
+
'no-shadow': 'off',
|
|
25
|
+
'no-return-await': 'off',
|
|
26
|
+
|
|
27
|
+
// TypeScript unused vars - use plugin for auto-fix
|
|
22
28
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
29
|
+
|
|
30
|
+
// Promise handling - critical for async code
|
|
23
31
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
24
32
|
'@typescript-eslint/no-misused-promises': 'error',
|
|
33
|
+
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
|
|
34
|
+
|
|
35
|
+
// Type imports - cleaner bundles
|
|
25
36
|
'@typescript-eslint/consistent-type-imports': [
|
|
26
37
|
'error',
|
|
27
|
-
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }
|
|
38
|
+
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
|
|
39
|
+
],
|
|
40
|
+
'@typescript-eslint/consistent-type-exports': [
|
|
41
|
+
'error',
|
|
42
|
+
{ fixMixedExportsWithInlineTypeSpecifier: true },
|
|
28
43
|
],
|
|
44
|
+
|
|
45
|
+
// Type safety - balanced for real-world use
|
|
29
46
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
30
47
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
31
48
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
32
49
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
50
|
+
'@typescript-eslint/no-unnecessary-condition': 'off',
|
|
51
|
+
|
|
52
|
+
// Modern TypeScript features
|
|
33
53
|
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
|
34
|
-
'@typescript-eslint/prefer-optional-chain': 'warn'
|
|
35
|
-
|
|
54
|
+
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
55
|
+
'@typescript-eslint/prefer-as-const': 'warn',
|
|
56
|
+
|
|
57
|
+
// Safety
|
|
58
|
+
'@typescript-eslint/no-shadow': 'warn',
|
|
59
|
+
'@typescript-eslint/no-require-imports': 'warn',
|
|
60
|
+
'@typescript-eslint/ban-ts-comment': [
|
|
61
|
+
'warn',
|
|
62
|
+
{
|
|
63
|
+
'ts-expect-error': 'allow-with-description',
|
|
64
|
+
'ts-ignore': true,
|
|
65
|
+
'ts-nocheck': true,
|
|
66
|
+
'ts-check': false,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
36
70
|
}
|
package/eslint/vue.js
CHANGED
|
@@ -9,13 +9,13 @@ module.exports = {
|
|
|
9
9
|
parser: require('@typescript-eslint/parser'),
|
|
10
10
|
ecmaVersion: 'latest',
|
|
11
11
|
sourceType: 'module',
|
|
12
|
-
project: true
|
|
13
|
-
}
|
|
12
|
+
project: true,
|
|
13
|
+
},
|
|
14
14
|
},
|
|
15
15
|
plugins: {
|
|
16
16
|
...base.plugins,
|
|
17
17
|
vue: require('eslint-plugin-vue'),
|
|
18
|
-
'@typescript-eslint': require('@typescript-eslint/eslint-plugin')
|
|
18
|
+
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
|
|
19
19
|
},
|
|
20
20
|
rules: {
|
|
21
21
|
...base.rules,
|
|
@@ -25,7 +25,7 @@ module.exports = {
|
|
|
25
25
|
'@typescript-eslint/no-misused-promises': 'error',
|
|
26
26
|
'@typescript-eslint/consistent-type-imports': [
|
|
27
27
|
'error',
|
|
28
|
-
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' }
|
|
28
|
+
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
|
|
29
29
|
],
|
|
30
30
|
|
|
31
31
|
'vue/component-name-in-template-casing': ['warn', 'PascalCase'],
|
|
@@ -57,8 +57,8 @@ module.exports = {
|
|
|
57
57
|
'vue/component-tags-order': [
|
|
58
58
|
'warn',
|
|
59
59
|
{
|
|
60
|
-
order: ['script', 'template', 'style']
|
|
61
|
-
}
|
|
60
|
+
order: ['script', 'template', 'style'],
|
|
61
|
+
},
|
|
62
62
|
],
|
|
63
63
|
'vue/define-emits-declaration': 'warn',
|
|
64
64
|
'vue/define-props-declaration': 'warn',
|
|
@@ -96,6 +96,6 @@ module.exports = {
|
|
|
96
96
|
'vue/valid-v-pre': 'error',
|
|
97
97
|
'vue/valid-v-show': 'error',
|
|
98
98
|
'vue/valid-v-slot': 'error',
|
|
99
|
-
'vue/valid-v-text': 'error'
|
|
100
|
-
}
|
|
99
|
+
'vue/valid-v-text': 'error',
|
|
100
|
+
},
|
|
101
101
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itstandu/code-style",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Production-ready shared ESLint + Prettier configuration for JavaScript and TypeScript projects",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|
|
@@ -42,29 +42,29 @@
|
|
|
42
42
|
"node": ">=18.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@angular-eslint/eslint-plugin": "
|
|
46
|
-
"@angular-eslint/eslint-plugin-template": "
|
|
47
|
-
"@angular-eslint/template-parser": "
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "
|
|
49
|
-
"@typescript-eslint/parser": "
|
|
50
|
-
"eslint": "
|
|
51
|
-
"eslint-config-prettier": "
|
|
52
|
-
"eslint-plugin-boundaries": "
|
|
53
|
-
"eslint-plugin-import": "
|
|
54
|
-
"eslint-plugin-jsx-a11y": "
|
|
55
|
-
"eslint-plugin-n": "
|
|
56
|
-
"eslint-plugin-promise": "
|
|
57
|
-
"eslint-plugin-react": "
|
|
58
|
-
"eslint-plugin-react-hooks": "
|
|
59
|
-
"eslint-plugin-simple-import-sort": "
|
|
60
|
-
"eslint-plugin-sonarjs": "
|
|
61
|
-
"eslint-plugin-unicorn": "
|
|
62
|
-
"eslint-plugin-unused-imports": "
|
|
63
|
-
"eslint-plugin-vue": "
|
|
64
|
-
"@prettier/plugin-oxc": "
|
|
65
|
-
"prettier": "
|
|
66
|
-
"prettier-plugin-tailwindcss": "
|
|
67
|
-
"vue-eslint-parser": "
|
|
45
|
+
"@angular-eslint/eslint-plugin": "^19.0.0",
|
|
46
|
+
"@angular-eslint/eslint-plugin-template": "^19.0.0",
|
|
47
|
+
"@angular-eslint/template-parser": "^19.0.0",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
49
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
50
|
+
"eslint": "^9.0.0",
|
|
51
|
+
"eslint-config-prettier": "^10.0.0",
|
|
52
|
+
"eslint-plugin-boundaries": "^5.0.0",
|
|
53
|
+
"eslint-plugin-import": "^2.31.0",
|
|
54
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
55
|
+
"eslint-plugin-n": "^17.0.0",
|
|
56
|
+
"eslint-plugin-promise": "^7.0.0",
|
|
57
|
+
"eslint-plugin-react": "^7.37.0",
|
|
58
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
59
|
+
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
60
|
+
"eslint-plugin-sonarjs": "^3.0.0",
|
|
61
|
+
"eslint-plugin-unicorn": "^56.0.0",
|
|
62
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
63
|
+
"eslint-plugin-vue": "^9.32.0",
|
|
64
|
+
"@prettier/plugin-oxc": "^0.0.11",
|
|
65
|
+
"prettier": "^3.4.0",
|
|
66
|
+
"prettier-plugin-tailwindcss": "^0.6.0",
|
|
67
|
+
"vue-eslint-parser": "^9.4.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"typescript": ">=5.0.0"
|
package/prettier/index.cjs
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
// Basic formatting
|
|
2
3
|
semi: false,
|
|
3
4
|
singleQuote: true,
|
|
4
5
|
trailingComma: 'all',
|
|
5
6
|
printWidth: 100,
|
|
6
7
|
tabWidth: 2,
|
|
7
8
|
useTabs: false,
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
// Bracket and spacing
|
|
10
11
|
bracketSpacing: true,
|
|
11
12
|
bracketSameLine: false,
|
|
13
|
+
arrowParens: 'always',
|
|
14
|
+
|
|
15
|
+
// JSX/HTML specific
|
|
16
|
+
jsxSingleQuote: false,
|
|
17
|
+
singleAttributePerLine: false,
|
|
18
|
+
|
|
19
|
+
// Quotes
|
|
20
|
+
quoteProps: 'as-needed',
|
|
21
|
+
|
|
22
|
+
// Line endings and whitespace
|
|
23
|
+
endOfLine: 'lf',
|
|
12
24
|
proseWrap: 'preserve',
|
|
13
25
|
htmlWhitespaceSensitivity: 'css',
|
|
26
|
+
|
|
27
|
+
// Vue specific
|
|
28
|
+
vueIndentScriptAndStyle: false,
|
|
29
|
+
|
|
30
|
+
// Pragma (for legacy systems)
|
|
14
31
|
insertPragma: false,
|
|
15
|
-
jsxSingleQuote: false,
|
|
16
|
-
quoteProps: 'as-needed',
|
|
17
32
|
requirePragma: false,
|
|
18
|
-
vueIndentScriptAndStyle: false,
|
|
19
33
|
|
|
20
|
-
|
|
34
|
+
// Embedded language formatting
|
|
35
|
+
embeddedLanguageFormatting: 'auto',
|
|
36
|
+
|
|
37
|
+
// Plugins - order matters: oxc first for parsing, tailwindcss last for class sorting
|
|
38
|
+
plugins: ['@prettier/plugin-oxc', 'prettier-plugin-tailwindcss'],
|
|
21
39
|
}
|