linter-bundle 3.9.0 → 4.0.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/.linter-bundle.js +51 -0
- package/CHANGELOG.md +25 -1
- package/README.md +372 -93
- package/TODO.md +10 -19
- package/eslint/index.js +5 -4
- package/eslint/overrides-react.js +3 -2
- package/eslint/rules/no-global-undefined-check.md +1 -1
- package/eslint/rules/restricted-filenames.js +51 -41
- package/eslint/rules/restricted-filenames.md +20 -16
- package/files/index.js +100 -0
- package/helper/config.js +48 -0
- package/helper/get-git-files.js +52 -0
- package/helper/run-process.js +2 -1
- package/lint.js +330 -196
- package/package.json +6 -6
- package/stylelint/index.js +4 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const snippets = {
|
|
2
|
+
lowerCase: '[a-z]*([a-z0-9])',
|
|
3
|
+
upperCase: '[A-Z]*([A-Z0-9])',
|
|
4
|
+
snakeCase: '[a-z]*(*([a-z0-9]_)+([a-z0-9]))',
|
|
5
|
+
screamingSnakeCase: '[A-Z]*(*([A-Z0-9]_)+([A-Z0-9]))',
|
|
6
|
+
kebabCase: '[a-z]*(*([a-z0-9]-)+([a-z0-9]))',
|
|
7
|
+
camelCase: '[a-z]*([a-zA-Z0-9])',
|
|
8
|
+
pascalCase: '[A-Z]*([a-zA-Z0-9])'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
files: {
|
|
13
|
+
git: true,
|
|
14
|
+
restrictions: [
|
|
15
|
+
{
|
|
16
|
+
basePath: '.',
|
|
17
|
+
allowed: [
|
|
18
|
+
'.git/**',
|
|
19
|
+
'.github/FUNDING.yml',
|
|
20
|
+
'.vscode/settings.json',
|
|
21
|
+
`eslint/rules/${snippets.kebabCase}.{js,md}`,
|
|
22
|
+
`eslint/{index.js,overrides-${snippets.kebabCase}.js}`,
|
|
23
|
+
'files/index.js',
|
|
24
|
+
`helper/${snippets.kebabCase}.js`,
|
|
25
|
+
'markdownlint/base.json',
|
|
26
|
+
'node_modules/**',
|
|
27
|
+
'stylelint/index.js',
|
|
28
|
+
`stylelint/plugins/stylelint-${snippets.kebabCase}.js`,
|
|
29
|
+
'.editorconfig',
|
|
30
|
+
'.eslintrc.js',
|
|
31
|
+
'.gitattributes',
|
|
32
|
+
'.gitignore',
|
|
33
|
+
'.linter-bundle.js',
|
|
34
|
+
'.markdownlint.json',
|
|
35
|
+
'.npmignore',
|
|
36
|
+
'*.md',
|
|
37
|
+
'LICENSE',
|
|
38
|
+
'lint.js',
|
|
39
|
+
'package-lock.json',
|
|
40
|
+
'package.json',
|
|
41
|
+
'stylelint.config.js',
|
|
42
|
+
'tsconfig.json',
|
|
43
|
+
'types.d.ts',
|
|
44
|
+
'validate-stylelint-options.mjs',
|
|
45
|
+
'vscode-eslint-1.png',
|
|
46
|
+
'vscode-eslint-2.png'
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/
|
|
9
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v4.0.0...HEAD)
|
|
10
|
+
|
|
11
|
+
## [4.0.0] - 2023-08-30
|
|
12
|
+
|
|
13
|
+
### Breaking change
|
|
14
|
+
|
|
15
|
+
- [general] The global configuration variable `global.linterBundleSettings` has been replaced by a `.linter-bundle.json` / `.linter-bundle.cjs` / `.linter-bundle.js` configuration file in the projects root directory
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- [eslint] Updated `eslint-plugin-jsdoc` from `46.5.0` to `46.5.1`
|
|
20
|
+
|
|
21
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.10.0...v4.0.0)
|
|
22
|
+
|
|
23
|
+
## [3.10.0] - 2023-08-29
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- [eslint] Updated `@typescript-eslint` from `6.4.1` to `6.5.0`
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- [eslint] Don't consider files outside of `basePath` in [`restricted-filenames`](./eslint/rules/restricted-filenames.md) rule
|
|
32
|
+
|
|
33
|
+
[Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v3.9.0...v3.10.0)
|
|
10
34
|
|
|
11
35
|
## [3.9.0] - 2023-08-28
|
|
12
36
|
|
package/README.md
CHANGED
|
@@ -83,8 +83,6 @@ npm install linter-bundle --save-dev
|
|
|
83
83
|
|
|
84
84
|
#### .eslintrc.js
|
|
85
85
|
|
|
86
|
-
##### Minimum configuration
|
|
87
|
-
|
|
88
86
|
```js
|
|
89
87
|
module.exports = {
|
|
90
88
|
extends: [
|
|
@@ -102,90 +100,6 @@ module.exports = {
|
|
|
102
100
|
};
|
|
103
101
|
```
|
|
104
102
|
|
|
105
|
-
##### Maximum configuration
|
|
106
|
-
|
|
107
|
-
```js
|
|
108
|
-
// Sometimes it's required to adjust specific settings. These can be defined here:
|
|
109
|
-
global.linterBundleSettings = {
|
|
110
|
-
overrides: {
|
|
111
|
-
general: {
|
|
112
|
-
'no-restricted-globals': {
|
|
113
|
-
additionalRestrictions: [
|
|
114
|
-
{
|
|
115
|
-
name: 'fetch',
|
|
116
|
-
message: 'Use Utils.fetchWithTimeout() instead.'
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
'no-restricted-properties': {
|
|
121
|
-
additionalRestrictions: [
|
|
122
|
-
{
|
|
123
|
-
object: 'localStorage',
|
|
124
|
-
property: 'getItem',
|
|
125
|
-
message: 'Use StorageHelper.getItem() instead.'
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
object: 'localStorage',
|
|
129
|
-
property: 'setItem',
|
|
130
|
-
message: 'Use StorageHelper.setItem() instead.'
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
object: 'localStorage',
|
|
134
|
-
property: 'removeItem',
|
|
135
|
-
message: 'Use StorageHelper.removeItem() instead.'
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
},
|
|
139
|
-
'no-restricted-syntax': {
|
|
140
|
-
additionalRestrictions: [
|
|
141
|
-
{
|
|
142
|
-
selector: 'NewExpression[callee.name="Blob"]',
|
|
143
|
-
message: 'Use BlobHelper.create() instead of new Blob().'
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
},
|
|
147
|
-
'import/order': {
|
|
148
|
-
additionalExternalPatterns: ['@sentry/*']
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
react: {
|
|
152
|
-
'react/forbid-component-props': {
|
|
153
|
-
allowClassNameFor: ['Checkbox', 'Grid', 'GridItem', 'Button'],
|
|
154
|
-
allowStyleFor: []
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
module.exports = {
|
|
161
|
-
extends: [
|
|
162
|
-
require.resolve('linter-bundle/eslint'),
|
|
163
|
-
require.resolve('linter-bundle/eslint/overrides-gatsby'),
|
|
164
|
-
require.resolve('linter-bundle/eslint/overrides-javascript'),
|
|
165
|
-
// require.resolve('linter-bundle/eslint/overrides-javascript-lazy'),
|
|
166
|
-
require.resolve('linter-bundle/eslint/overrides-jest'),
|
|
167
|
-
require.resolve('linter-bundle/eslint/overrides-jsdoc'),
|
|
168
|
-
require.resolve('linter-bundle/eslint/overrides-react'),
|
|
169
|
-
require.resolve('linter-bundle/eslint/overrides-storybook'),
|
|
170
|
-
require.resolve('linter-bundle/eslint/overrides-type-declarations'),
|
|
171
|
-
require.resolve('linter-bundle/eslint/overrides-worker')
|
|
172
|
-
],
|
|
173
|
-
ignorePatterns: [
|
|
174
|
-
// Define paths which should be ignored here. (The following paths are ignored by default: '.cache/', '.vscode/', 'coverage/', 'node_modules/')
|
|
175
|
-
'build/',
|
|
176
|
-
'etc/',
|
|
177
|
-
'private/'
|
|
178
|
-
],
|
|
179
|
-
globals: {
|
|
180
|
-
// Define project-specific global variables. JavaScript built-in objects (like ArrayBuffer, typed arrays, Promise, Set/Map etc.) are automatically set to
|
|
181
|
-
// 'readonly', and don't need to be added here.
|
|
182
|
-
__DEV__: 'readonly',
|
|
183
|
-
APP_NAME: 'readonly',
|
|
184
|
-
APP_VERSION: 'readonly',
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
```
|
|
188
|
-
|
|
189
103
|
##### Available `extends`
|
|
190
104
|
|
|
191
105
|
Source | Description | Rules setup
|
|
@@ -204,11 +118,6 @@ Source | Description | Rules setup
|
|
|
204
118
|
#### stylelint.config.js
|
|
205
119
|
|
|
206
120
|
```js
|
|
207
|
-
global.linterBundleSettings = {
|
|
208
|
-
// The prefix used for the 'custom-media-pattern' (`@media (--my-prefix-foo)`) and 'custom-property-pattern' (`var(--my-prefix-bar)`) rule. If not defined, these rules are disabled.
|
|
209
|
-
propertyPrefix: 'my-prefix'
|
|
210
|
-
};
|
|
211
|
-
|
|
212
121
|
module.exports = {
|
|
213
122
|
extends: 'linter-bundle/stylelint'
|
|
214
123
|
};
|
|
@@ -229,13 +138,379 @@ module.exports = {
|
|
|
229
138
|
.eslintcache
|
|
230
139
|
```
|
|
231
140
|
|
|
141
|
+
### .linter-bundle.json / .linter-bundle.cjs / .linter-bundle.js
|
|
142
|
+
|
|
143
|
+
`linter-bundle` supports a couple of additional options, which can be configured in the configuration file, in the root of your project.
|
|
144
|
+
Some of the options are also available as command line arguments (see below).
|
|
145
|
+
The file itself, and any of the options is optional.
|
|
146
|
+
|
|
147
|
+
#### Minimum example configuration (`.linter-bundle.json`)
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"verbose": true,
|
|
152
|
+
"timing": true,
|
|
153
|
+
"git": true,
|
|
154
|
+
"tsc": {
|
|
155
|
+
"tsconfig": "./tsconfig.lint.json"
|
|
156
|
+
},
|
|
157
|
+
"ts": {
|
|
158
|
+
"tsconfig": "./tsconfig.lint.json",
|
|
159
|
+
"include": ["./included/*.ts"],
|
|
160
|
+
"exclude": ["./excluded/*.ts"],
|
|
161
|
+
"overrides": {
|
|
162
|
+
"general": {
|
|
163
|
+
"no-restricted-globals": {
|
|
164
|
+
"additionalRestrictions": [
|
|
165
|
+
{
|
|
166
|
+
"name": "fetch",
|
|
167
|
+
"message": "Use Utils.fetchWithTimeout() instead."
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
"no-restricted-properties": {
|
|
172
|
+
"additionalRestrictions": [
|
|
173
|
+
{
|
|
174
|
+
"object": "localStorage",
|
|
175
|
+
"property": "getItem",
|
|
176
|
+
"message": "Use StorageHelper.getItem() instead."
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
"no-restricted-syntax": {
|
|
181
|
+
"additionalRestrictions": [
|
|
182
|
+
{
|
|
183
|
+
"selector": "NewExpression[callee.name=\"Blob\"]",
|
|
184
|
+
"message": "Use BlobHelper.create() instead of new Blob()."
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
"import/order": {
|
|
189
|
+
"additionalExternalPatterns": ["@sentry/*"]
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"react": {
|
|
193
|
+
"react/forbid-component-props": {
|
|
194
|
+
"allowClassNameFor": ["Checkbox", "Grid", "GridItem", "Button"],
|
|
195
|
+
"allowStyleFor": ["Grid", "GridItem"]
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"sass": {
|
|
201
|
+
"include": ["./included/*.ts"],
|
|
202
|
+
"patternPrefix": "--my-prefix"
|
|
203
|
+
},
|
|
204
|
+
"md": {
|
|
205
|
+
"include": ["./included/*.md"],
|
|
206
|
+
},
|
|
207
|
+
"audit": {
|
|
208
|
+
"minSeverity": "high",
|
|
209
|
+
"exclude": ["975", "1751"]
|
|
210
|
+
},
|
|
211
|
+
"files": {
|
|
212
|
+
"restrictions": [
|
|
213
|
+
{
|
|
214
|
+
"basePath": "./src",
|
|
215
|
+
"allow": [
|
|
216
|
+
"components/**/index.tsx",
|
|
217
|
+
"utils/{index.ts,lib/[a-z]+([a-zA-Z])?(.spec).ts}"
|
|
218
|
+
],
|
|
219
|
+
"disallow": [
|
|
220
|
+
"components/NotAllowed/index.tsx"
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Maximum example configuration (`.linter-bundle.js`)
|
|
229
|
+
|
|
230
|
+
<!-- markdownlint-disable-next-line MD033 -->
|
|
231
|
+
<details><summary>Click here to see the example configuration with descriptions</summary>
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
module.exports = {
|
|
235
|
+
/**
|
|
236
|
+
* Same as `--verbose` command line argument.
|
|
237
|
+
*
|
|
238
|
+
* @type {boolean}
|
|
239
|
+
*/
|
|
240
|
+
verbose: true,
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Same as `--timing` command line argument.
|
|
244
|
+
*
|
|
245
|
+
* @type {boolean}
|
|
246
|
+
*/
|
|
247
|
+
timing: true,
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Same as `--git` command line argument.
|
|
251
|
+
*
|
|
252
|
+
* @type {boolean}
|
|
253
|
+
*/
|
|
254
|
+
git: true,
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Configuration, specific to the `tsc` command.
|
|
258
|
+
*/
|
|
259
|
+
tsc: {
|
|
260
|
+
/**
|
|
261
|
+
* `verbose`, `timing` and `git` are the same as in the root node.
|
|
262
|
+
*/
|
|
263
|
+
verbose: true,
|
|
264
|
+
timing: true,
|
|
265
|
+
git: true,
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Same as `--tsconfig` command line argument.
|
|
269
|
+
*
|
|
270
|
+
* @type {string}
|
|
271
|
+
*/
|
|
272
|
+
tsconfig: './tsconfig.lint.json'
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Configuration, specific to the `ts` command.
|
|
277
|
+
*/
|
|
278
|
+
ts: {
|
|
279
|
+
/**
|
|
280
|
+
* `verbose`, `timing` and `git` are the same as in the root node.
|
|
281
|
+
*/
|
|
282
|
+
verbose: true,
|
|
283
|
+
timing: true,
|
|
284
|
+
git: true,
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Same as `--tsconfig` command line argument.
|
|
288
|
+
*
|
|
289
|
+
* @type {string}
|
|
290
|
+
*/
|
|
291
|
+
tsconfig: './tsconfig.lint.json',
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Same as `--include` command line argument.
|
|
295
|
+
*
|
|
296
|
+
* @type {string[]}
|
|
297
|
+
*/
|
|
298
|
+
include: ['./included/*.ts'],
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Same as `--exclude` command line argument.
|
|
302
|
+
*
|
|
303
|
+
* @type {string[]}
|
|
304
|
+
*/
|
|
305
|
+
exclude: ['./excluded/*.ts'],
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Overrides and extensions for specific ESLint rules.
|
|
309
|
+
*/
|
|
310
|
+
overrides: {
|
|
311
|
+
/**
|
|
312
|
+
* Rules that are applied to `linter-bundle/eslint`.
|
|
313
|
+
*/
|
|
314
|
+
general: {
|
|
315
|
+
'no-restricted-globals': {
|
|
316
|
+
/**
|
|
317
|
+
* Extend the `restrictions` of the `no-restricted-globals` rule.
|
|
318
|
+
*
|
|
319
|
+
* @type {{ name: string; message: string; }[]}
|
|
320
|
+
*/
|
|
321
|
+
additionalRestrictions: [
|
|
322
|
+
{
|
|
323
|
+
name: 'fetch',
|
|
324
|
+
message: 'Use Utils.fetchWithTimeout() instead.'
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
'no-restricted-properties': {
|
|
329
|
+
/**
|
|
330
|
+
* Extend the `restrictions` of the `no-restricted-properties` rule.
|
|
331
|
+
*
|
|
332
|
+
* @type {{ object: string; property: string; message: string; }[]}
|
|
333
|
+
*/
|
|
334
|
+
additionalRestrictions: [
|
|
335
|
+
{
|
|
336
|
+
object: 'localStorage',
|
|
337
|
+
property: 'getItem',
|
|
338
|
+
message: 'Use StorageHelper.getItem() instead.'
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
'no-restricted-syntax': {
|
|
343
|
+
/**
|
|
344
|
+
* Extend the `restrictions` of the `no-restricted-syntax` rule.
|
|
345
|
+
*
|
|
346
|
+
* @type {{ selector: string; message: string; }[]}
|
|
347
|
+
*/
|
|
348
|
+
additionalRestrictions: [
|
|
349
|
+
{
|
|
350
|
+
selector: 'NewExpression[callee.name="Blob"]',
|
|
351
|
+
message: 'Use BlobHelper.create() instead of new Blob().'
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
'import/order': {
|
|
356
|
+
/**
|
|
357
|
+
* Extend the `externalPatterns` of the `import/order` rule.
|
|
358
|
+
*
|
|
359
|
+
* @type {string[]}
|
|
360
|
+
*/
|
|
361
|
+
additionalExternalPatterns: ['@sentry/*']
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Rules that are applied to `linter-bundle/eslint/overrides-react`.
|
|
367
|
+
*/
|
|
368
|
+
react: {
|
|
369
|
+
'react/forbid-component-props': {
|
|
370
|
+
/**
|
|
371
|
+
* Allows the `className` property for the specified components.
|
|
372
|
+
*
|
|
373
|
+
* @type {string[]}
|
|
374
|
+
*/
|
|
375
|
+
allowClassNameFor: ['Checkbox', 'Grid', 'GridItem', 'Button'],
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Allows the `style` property for the specified components.
|
|
379
|
+
*
|
|
380
|
+
* @type {string[]}
|
|
381
|
+
*/
|
|
382
|
+
allowStyleFor: ['Grid', 'GridItem']
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Configuration, specific to the `sass` command.
|
|
390
|
+
*/
|
|
391
|
+
sass: {
|
|
392
|
+
/**
|
|
393
|
+
* `verbose`, `timing` and `git` are the same as in the root node.
|
|
394
|
+
*/
|
|
395
|
+
verbose: true,
|
|
396
|
+
timing: true,
|
|
397
|
+
git: true,
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Same as `--include` command line argument.
|
|
401
|
+
*
|
|
402
|
+
* @type {string[]}
|
|
403
|
+
*/
|
|
404
|
+
include: ['./included/*.ts'],
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The prefix used for the 'custom-media-pattern' (`@media (--my-prefix-foo)`) and 'custom-property-pattern' (`var(--my-prefix-bar)`) rule.
|
|
408
|
+
*
|
|
409
|
+
* If not defined, these rules are disabled.
|
|
410
|
+
*/
|
|
411
|
+
patternPrefix: '--my-prefix'
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Configuration, specific to the `audit` command.
|
|
416
|
+
*/
|
|
417
|
+
md: {
|
|
418
|
+
/**
|
|
419
|
+
* Same as `--include` command line argument.
|
|
420
|
+
*
|
|
421
|
+
* @type {string[]}
|
|
422
|
+
*/
|
|
423
|
+
include: ['./included/*.ts']
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Configuration, specific to the `audit` command.
|
|
428
|
+
*/
|
|
429
|
+
audit: {
|
|
430
|
+
/**
|
|
431
|
+
* `verbose`, `timing` and `git` are the same as in the root node.
|
|
432
|
+
*/
|
|
433
|
+
verbose: true,
|
|
434
|
+
timing: true,
|
|
435
|
+
git: true,
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Same as `--min-severity` command line argument.
|
|
439
|
+
*
|
|
440
|
+
* @type {'info' | 'low' | 'moderate' | 'high' | 'critical'}
|
|
441
|
+
*/
|
|
442
|
+
minSeverity: 'high',
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Same as `--exclude` command line argument.
|
|
446
|
+
*
|
|
447
|
+
* @type {string[]}
|
|
448
|
+
*/
|
|
449
|
+
exclude: ['975', '1751']
|
|
450
|
+
},
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Configuration, specific to the `files` command.
|
|
454
|
+
*/
|
|
455
|
+
files: {
|
|
456
|
+
/**
|
|
457
|
+
* `verbose`, `timing` and `git` are the same as in the root node.
|
|
458
|
+
*/
|
|
459
|
+
verbose: true,
|
|
460
|
+
timing: true,
|
|
461
|
+
git: true,
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Array of restrictions for different base paths.
|
|
465
|
+
*
|
|
466
|
+
* The configuration is equal to the `restricted-filenames` ESLint plugin.
|
|
467
|
+
* This plugin is using the configuration here, if ESLint is used outside of `linter-bundle` (e.g. in VSCode).
|
|
468
|
+
*
|
|
469
|
+
* @see https://github.com/jens-duttke/linter-bundle/blob/main/eslint/rules/restricted-filenames.md
|
|
470
|
+
*/
|
|
471
|
+
restrictions: [
|
|
472
|
+
{
|
|
473
|
+
/**
|
|
474
|
+
* Same as `--exclude` command line argument.
|
|
475
|
+
*
|
|
476
|
+
* @type {string}
|
|
477
|
+
*/
|
|
478
|
+
basePath: './src',
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Glob pattern Same as `--exclude` command line argument.
|
|
482
|
+
*
|
|
483
|
+
* @type {string[]}
|
|
484
|
+
*/
|
|
485
|
+
allow: [
|
|
486
|
+
'components/**/index.tsx',
|
|
487
|
+
'utils/{index.ts,lib/[a-z]+([a-zA-Z])?(.spec).ts}'
|
|
488
|
+
],
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Same as `--exclude` command line argument.
|
|
492
|
+
*
|
|
493
|
+
* @type {string[]}
|
|
494
|
+
*
|
|
495
|
+
*/
|
|
496
|
+
disallow: [
|
|
497
|
+
'components/NotAllowed/index.tsx'
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
</details>
|
|
506
|
+
|
|
232
507
|
## Available commands
|
|
233
508
|
|
|
234
509
|
The command line arguments are separated in groups. Here are some examples:
|
|
235
510
|
|
|
236
511
|
```sh
|
|
237
|
-
# Run TypeScript compiler, ESLint, Stylelint, Markdownlint, and audit in the given order, using the default configuration
|
|
238
|
-
lint tsc ts sass md audit
|
|
512
|
+
# Run File restrictions, TypeScript compiler, ESLint, Stylelint, Markdownlint, and audit in the given order, using the default configuration
|
|
513
|
+
lint files tsc ts sass md audit
|
|
239
514
|
|
|
240
515
|
# Run ESLint and Audit, and show their terminal output even on success
|
|
241
516
|
lint --verbose ts audit
|
|
@@ -260,6 +535,10 @@ Argument | Description | Example
|
|
|
260
535
|
`--timing` | Show information how long each linting process was running. | `--timing`
|
|
261
536
|
`--git` | **Experimental** Only lint (ESLint, Stylelint and Markdownlint) files which have been detected as changed (compared to the upstream branch) by Git. This can result into massive performance improvements on large code bases, but also lead to undetected issues with cross-file rules. | `--git`
|
|
262
537
|
|
|
538
|
+
### `lint files`
|
|
539
|
+
|
|
540
|
+
Will check if the files in the project match the restrictions defined in the linter-bundle configuration file.
|
|
541
|
+
|
|
263
542
|
### `lint tsc`
|
|
264
543
|
|
|
265
544
|
Will execute:
|
package/TODO.md
CHANGED
|
@@ -2,15 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- markdownlint-disable -->
|
|
4
4
|
|
|
5
|
-
- Keine Hard-kodierten HexEdit-spezifischen Werte:
|
|
6
|
-
react: {
|
|
7
|
-
'react/forbid-component-props': {
|
|
8
|
-
allowClassNameFor: ['Checkbox', 'Grid', 'GridItem', 'Button'],
|
|
9
|
-
allowStyleFor: []
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
Diese müssen konfigurierbar sein. Hier gibt es neu auch `disallowFor`, aber ggf. sollte das gesammte Konfig-Objekt von aussen kommen.
|
|
13
|
-
|
|
14
5
|
- Bereiche in Readme aufklappbar machen:
|
|
15
6
|
<details>
|
|
16
7
|
summary>yarn</summary>
|
|
@@ -20,12 +11,12 @@ yarn add click-to-react-component
|
|
|
20
11
|
```
|
|
21
12
|
</details>
|
|
22
13
|
|
|
23
|
-
- Make git diff-branch configurable
|
|
24
|
-
on GitHub Actions this could be used:
|
|
25
|
-
- run: git diff --name-only -z origin/${GITHUB_BASE_REF}
|
|
14
|
+
- Make git diff-branch configurable
|
|
15
|
+
on GitHub Actions this could be used:
|
|
16
|
+
- run: git diff --name-only -z origin/${GITHUB_BASE_REF}
|
|
26
17
|
Is there a variable with includes origin/ already?
|
|
27
18
|
|
|
28
|
-
Some tools like Gatsby ship deprecated dependencies of eslint and @typescript-eslint.
|
|
19
|
+
Some tools like Gatsby ship deprecated dependencies of eslint and @typescript-eslint.
|
|
29
20
|
Since npm installs packages alphabetically, the outdated `gatsby` dependencies are installed in the `node_modules` root, instead of the newer `linter-bundle` dependencies. Since the old versions often do not support new rules or new options, this may cause linting to fail with errors like this:
|
|
30
21
|
|
|
31
22
|
```bash
|
|
@@ -47,11 +38,11 @@ By using the `enforce-deps` option, linter-bundle will ensure the right versions
|
|
|
47
38
|
```
|
|
48
39
|
|
|
49
40
|
- Option to lint only changed files in Git
|
|
50
|
-
[lint-staged](https://github.com/okonet/lint-staged)
|
|
51
|
-
[affected](https://www.npmjs.com/package/affected)
|
|
52
|
-
[git-affected-files](https://www.npmjs.com/package/git-affected-files)
|
|
53
|
-
[affected-files](https://www.npmjs.com/package/affected-files)
|
|
54
|
-
[is-affected](https://www.npmjs.com/package/is-affected)
|
|
41
|
+
- [lint-staged](https://github.com/okonet/lint-staged)
|
|
42
|
+
- [affected](https://www.npmjs.com/package/affected)
|
|
43
|
+
- [git-affected-files](https://www.npmjs.com/package/git-affected-files)
|
|
44
|
+
- [affected-files](https://www.npmjs.com/package/affected-files)
|
|
45
|
+
- [is-affected](https://www.npmjs.com/package/is-affected)
|
|
55
46
|
|
|
56
|
-
- Find stylelint rule which checks for wrong values like:
|
|
47
|
+
- Find stylelint rule which checks for wrong values like:
|
|
57
48
|
`padding-top: 3px 3px 0;`
|
package/eslint/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const fs = require('node:fs');
|
|
9
9
|
const path = require('node:path');
|
|
10
10
|
|
|
11
|
+
const config = require('../helper/config.js');
|
|
11
12
|
const ensureType = require('../helper/ensure-type');
|
|
12
13
|
|
|
13
14
|
module.exports = {
|
|
@@ -282,16 +283,16 @@ module.exports = {
|
|
|
282
283
|
name: 'isNaN',
|
|
283
284
|
message: 'Use Number.isNaN() instead, and ensure that the input value is of type number. isNaN(undefined) !== Number.isNaN(undefined)'
|
|
284
285
|
},
|
|
285
|
-
...ensureType.array(
|
|
286
|
+
...ensureType.array(config.ts?.overrides?.general?.['no-restricted-globals']?.additionalRestrictions)
|
|
286
287
|
],
|
|
287
288
|
'no-restricted-imports': 'off', // Covered by @typescript-eslint/no-restricted-imports
|
|
288
289
|
'no-restricted-properties': [
|
|
289
290
|
'error',
|
|
290
|
-
...ensureType.array(
|
|
291
|
+
...ensureType.array(config.ts?.overrides?.general?.['no-restricted-properties']?.additionalRestrictions)
|
|
291
292
|
],
|
|
292
293
|
'no-restricted-syntax': [
|
|
293
294
|
'error',
|
|
294
|
-
...ensureType.array(
|
|
295
|
+
...ensureType.array(config.ts?.overrides?.general?.['no-restricted-syntax']?.additionalRestrictions)
|
|
295
296
|
],
|
|
296
297
|
'no-return-assign': 'error',
|
|
297
298
|
'no-script-url': 'error',
|
|
@@ -865,7 +866,7 @@ module.exports = {
|
|
|
865
866
|
'newlines-between': 'always',
|
|
866
867
|
'pathGroupsExcludedImportTypes': [],
|
|
867
868
|
'pathGroups': [
|
|
868
|
-
...ensureType.array(
|
|
869
|
+
...ensureType.array(config.ts?.overrides?.general?.['import/order']?.additionalExternalPatterns).map(
|
|
869
870
|
/**
|
|
870
871
|
* Creates an "external" group using the additional external pattern configuration.
|
|
871
872
|
* @param {string} pattern - A given pattern
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* @file Settings for React code in TypeScript (TSX) files.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
const config = require('../helper/config.js');
|
|
5
6
|
const ensureType = require('../helper/ensure-type');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
@@ -90,11 +91,11 @@ module.exports = {
|
|
|
90
91
|
'react/forbid-component-props': ['error', { forbid: [
|
|
91
92
|
{
|
|
92
93
|
propName: 'className',
|
|
93
|
-
allowedFor: ensureType.array(
|
|
94
|
+
allowedFor: ensureType.array(config.ts?.overrides?.react?.['react/forbid-component-props']?.allowClassNameFor)
|
|
94
95
|
},
|
|
95
96
|
{
|
|
96
97
|
propName: 'style',
|
|
97
|
-
allowedFor: ensureType.array(
|
|
98
|
+
allowedFor: ensureType.array(config.ts?.overrides?.react?.['react/forbid-component-props']?.allowStyleFor)
|
|
98
99
|
}
|
|
99
100
|
] }],
|
|
100
101
|
'react/forbid-dom-props': 'error',
|