xo 0.58.0 → 0.59.1
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/config/plugins.cjs +16 -15
- package/lib/options-manager.js +24 -18
- package/package.json +25 -24
- package/readme.md +3 -3
package/config/plugins.cjs
CHANGED
|
@@ -14,8 +14,7 @@ module.exports = {
|
|
|
14
14
|
'no-use-extend-native',
|
|
15
15
|
'ava',
|
|
16
16
|
'unicorn',
|
|
17
|
-
|
|
18
|
-
// 'promise',
|
|
17
|
+
'promise',
|
|
19
18
|
'import',
|
|
20
19
|
'n', // eslint-plugin-node's successor
|
|
21
20
|
'eslint-comments',
|
|
@@ -181,21 +180,23 @@ module.exports = {
|
|
|
181
180
|
// TODO: Temporarily disabled until it becomes more mature.
|
|
182
181
|
'unicorn/no-useless-undefined': 'off',
|
|
183
182
|
|
|
183
|
+
// TODO: Enable it when I have tried it more in practice.
|
|
184
|
+
'unicorn/prefer-string-raw': 'off',
|
|
185
|
+
|
|
184
186
|
// TODO: Temporarily disabled as the rule is buggy.
|
|
185
187
|
'function-call-argument-newline': 'off',
|
|
186
188
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// 'promise/prefer-await-to-then': 'error',
|
|
189
|
+
'promise/param-names': 'error',
|
|
190
|
+
'promise/no-return-wrap': [
|
|
191
|
+
'error',
|
|
192
|
+
{
|
|
193
|
+
allowReject: true,
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
'promise/no-new-statics': 'error',
|
|
197
|
+
'promise/no-return-in-finally': 'error',
|
|
198
|
+
'promise/valid-params': 'error',
|
|
199
|
+
'promise/prefer-await-to-then': 'error',
|
|
199
200
|
|
|
200
201
|
'import/default': 'error',
|
|
201
202
|
'import/export': 'error',
|
|
@@ -356,7 +357,7 @@ module.exports = {
|
|
|
356
357
|
'n/process-exit-as-throw': 'error',
|
|
357
358
|
|
|
358
359
|
// Disabled as the rule doesn't exclude scripts executed with `node` but not referenced in 'bin'. See https://github.com/mysticatea/eslint-plugin-node/issues/96
|
|
359
|
-
// 'n/
|
|
360
|
+
// 'n/hashbang': 'error',
|
|
360
361
|
|
|
361
362
|
'n/no-deprecated-api': 'error',
|
|
362
363
|
|
package/lib/options-manager.js
CHANGED
|
@@ -101,7 +101,13 @@ The config files are searched starting from `options.filePath` if defined or `op
|
|
|
101
101
|
*/
|
|
102
102
|
const mergeWithFileConfig = async options => {
|
|
103
103
|
options.cwd = path.resolve(options.cwd || process.cwd());
|
|
104
|
-
|
|
104
|
+
|
|
105
|
+
const configExplorer = cosmiconfig(MODULE_NAME, {
|
|
106
|
+
searchPlaces: CONFIG_FILES,
|
|
107
|
+
loaders: {noExt: defaultLoaders['.json']},
|
|
108
|
+
stopDir: options.cwd,
|
|
109
|
+
});
|
|
110
|
+
|
|
105
111
|
const packageConfigExplorer = cosmiconfig('engines', {searchPlaces: ['package.json'], stopDir: options.cwd});
|
|
106
112
|
options.filePath &&= path.resolve(options.cwd, options.filePath);
|
|
107
113
|
|
|
@@ -342,58 +348,58 @@ const buildXOConfig = options => config => {
|
|
|
342
348
|
for (const [rule, ruleConfig] of Object.entries(ENGINE_RULES)) {
|
|
343
349
|
for (const minVersion of Object.keys(ruleConfig).sort(semver.rcompare)) {
|
|
344
350
|
if (!options.nodeVersion || semver.intersects(options.nodeVersion, `<${minVersion}`)) {
|
|
345
|
-
config.baseConfig.rules[rule]
|
|
351
|
+
config.baseConfig.rules[rule] ??= ruleConfig[minVersion];
|
|
346
352
|
}
|
|
347
353
|
}
|
|
348
354
|
}
|
|
349
355
|
|
|
350
356
|
if (options.nodeVersion) {
|
|
351
|
-
config.baseConfig.rules['n/no-unsupported-features/es-builtins']
|
|
352
|
-
config.baseConfig.rules['n/no-unsupported-features/es-syntax']
|
|
353
|
-
config.baseConfig.rules['n/no-unsupported-features/node-builtins']
|
|
357
|
+
config.baseConfig.rules['n/no-unsupported-features/es-builtins'] ??= ['error', {version: options.nodeVersion}];
|
|
358
|
+
config.baseConfig.rules['n/no-unsupported-features/es-syntax'] ??= ['error', {version: options.nodeVersion, ignores: ['modules']}];
|
|
359
|
+
config.baseConfig.rules['n/no-unsupported-features/node-builtins'] ??= ['error', {version: options.nodeVersion}];
|
|
354
360
|
}
|
|
355
361
|
|
|
356
362
|
if (options.space && !options.prettier) {
|
|
357
363
|
if (options.ts) {
|
|
358
|
-
config.baseConfig.rules['@typescript-eslint/indent']
|
|
364
|
+
config.baseConfig.rules['@typescript-eslint/indent'] ??= ['error', spaces, {SwitchCase: 1}];
|
|
359
365
|
} else {
|
|
360
|
-
config.baseConfig.rules.indent
|
|
366
|
+
config.baseConfig.rules.indent ??= ['error', spaces, {SwitchCase: 1}];
|
|
361
367
|
}
|
|
362
368
|
|
|
363
369
|
// Only apply if the user has the React plugin
|
|
364
370
|
if (options.cwd && resolveFrom.silent('eslint-plugin-react', options.cwd)) {
|
|
365
371
|
config.baseConfig.plugins.push('react');
|
|
366
|
-
config.baseConfig.rules['react/jsx-indent-props']
|
|
367
|
-
config.baseConfig.rules['react/jsx-indent']
|
|
372
|
+
config.baseConfig.rules['react/jsx-indent-props'] ??= ['error', spaces];
|
|
373
|
+
config.baseConfig.rules['react/jsx-indent'] ??= ['error', spaces];
|
|
368
374
|
}
|
|
369
375
|
}
|
|
370
376
|
|
|
371
377
|
if (options.semicolon === false && !options.prettier) {
|
|
372
378
|
if (options.ts) {
|
|
373
|
-
config.baseConfig.rules['@typescript-eslint/semi']
|
|
379
|
+
config.baseConfig.rules['@typescript-eslint/semi'] ??= ['error', 'never'];
|
|
374
380
|
} else {
|
|
375
|
-
config.baseConfig.rules.semi
|
|
381
|
+
config.baseConfig.rules.semi ??= ['error', 'never'];
|
|
376
382
|
}
|
|
377
383
|
|
|
378
|
-
config.baseConfig.rules['semi-spacing']
|
|
384
|
+
config.baseConfig.rules['semi-spacing'] ??= ['error', {
|
|
379
385
|
before: false,
|
|
380
386
|
after: true,
|
|
381
387
|
}];
|
|
382
388
|
}
|
|
383
389
|
|
|
384
390
|
if (options.ts) {
|
|
385
|
-
config.baseConfig.rules['unicorn/import-style']
|
|
386
|
-
config.baseConfig.rules['node/file-extension-in-import']
|
|
391
|
+
config.baseConfig.rules['unicorn/import-style'] ??= 'off';
|
|
392
|
+
config.baseConfig.rules['node/file-extension-in-import'] ??= 'off';
|
|
387
393
|
|
|
388
394
|
// Disabled because of https://github.com/benmosher/eslint-plugin-import/issues/1590
|
|
389
|
-
config.baseConfig.rules['import/export']
|
|
395
|
+
config.baseConfig.rules['import/export'] ??= 'off';
|
|
390
396
|
|
|
391
397
|
// Does not work when the TS definition exports a default const.
|
|
392
|
-
config.baseConfig.rules['import/default']
|
|
398
|
+
config.baseConfig.rules['import/default'] ??= 'off';
|
|
393
399
|
|
|
394
400
|
// Disabled as it doesn't work with TypeScript.
|
|
395
401
|
// This issue and some others: https://github.com/benmosher/eslint-plugin-import/issues/1341
|
|
396
|
-
config.baseConfig.rules['import/named']
|
|
402
|
+
config.baseConfig.rules['import/named'] ??= 'off';
|
|
397
403
|
}
|
|
398
404
|
|
|
399
405
|
config.baseConfig.settings['import/resolver'] = gatherImportResolvers(options);
|
|
@@ -438,7 +444,7 @@ const buildPrettierConfig = (options, prettierConfig) => config => {
|
|
|
438
444
|
config.baseConfig.extends.push('plugin:prettier/recommended');
|
|
439
445
|
|
|
440
446
|
// The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
|
|
441
|
-
config.baseConfig.rules['prettier/prettier']
|
|
447
|
+
config.baseConfig.rules['prettier/prettier'] ??= ['error', mergeWithPrettierConfig(options, prettierConfig)];
|
|
442
448
|
}
|
|
443
449
|
|
|
444
450
|
return config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.1",
|
|
4
4
|
"description": "JavaScript/TypeScript linter (ESLint wrapper) with great defaults",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "xojs/xo",
|
|
@@ -54,53 +54,54 @@
|
|
|
54
54
|
"typescript"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@eslint/eslintrc": "^3.0
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
59
|
-
"@typescript-eslint/parser": "^7.
|
|
57
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^7.16.1",
|
|
59
|
+
"@typescript-eslint/parser": "^7.16.1",
|
|
60
60
|
"arrify": "^3.0.0",
|
|
61
|
-
"cosmiconfig": "^
|
|
61
|
+
"cosmiconfig": "^9.0.0",
|
|
62
62
|
"define-lazy-prop": "^3.0.0",
|
|
63
63
|
"eslint": "^8.57.0",
|
|
64
64
|
"eslint-config-prettier": "^9.1.0",
|
|
65
|
-
"eslint-config-xo": "^0.
|
|
66
|
-
"eslint-config-xo-typescript": "^
|
|
65
|
+
"eslint-config-xo": "^0.45.0",
|
|
66
|
+
"eslint-config-xo-typescript": "^5.0.0",
|
|
67
67
|
"eslint-formatter-pretty": "^6.0.1",
|
|
68
68
|
"eslint-import-resolver-webpack": "^0.13.8",
|
|
69
69
|
"eslint-plugin-ava": "^14.0.0",
|
|
70
70
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
71
71
|
"eslint-plugin-import": "^2.29.1",
|
|
72
|
-
"eslint-plugin-n": "^
|
|
72
|
+
"eslint-plugin-n": "^17.9.0",
|
|
73
73
|
"eslint-plugin-no-use-extend-native": "^0.5.0",
|
|
74
|
-
"eslint-plugin-prettier": "^5.1
|
|
75
|
-
"eslint-plugin-
|
|
76
|
-
"
|
|
74
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
75
|
+
"eslint-plugin-promise": "^6.4.0",
|
|
76
|
+
"eslint-plugin-unicorn": "^54.0.0",
|
|
77
|
+
"esm-utils": "^4.3.0",
|
|
77
78
|
"find-cache-dir": "^5.0.0",
|
|
78
79
|
"find-up-simple": "^1.0.0",
|
|
79
80
|
"get-stdin": "^9.0.0",
|
|
80
|
-
"get-tsconfig": "^4.7.
|
|
81
|
-
"globby": "^14.0.
|
|
81
|
+
"get-tsconfig": "^4.7.5",
|
|
82
|
+
"globby": "^14.0.2",
|
|
82
83
|
"imurmurhash": "^0.1.4",
|
|
83
84
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
|
84
85
|
"lodash-es": "^4.17.21",
|
|
85
86
|
"meow": "^13.2.0",
|
|
86
|
-
"micromatch": "^4.0.
|
|
87
|
-
"open-editor": "^
|
|
88
|
-
"prettier": "^3.
|
|
89
|
-
"semver": "^7.6.
|
|
87
|
+
"micromatch": "^4.0.7",
|
|
88
|
+
"open-editor": "^5.0.0",
|
|
89
|
+
"prettier": "^3.3.3",
|
|
90
|
+
"semver": "^7.6.3",
|
|
90
91
|
"slash": "^5.1.0",
|
|
91
92
|
"to-absolute-glob": "^3.0.0",
|
|
92
|
-
"typescript": "^5.
|
|
93
|
+
"typescript": "^5.5.3"
|
|
93
94
|
},
|
|
94
95
|
"devDependencies": {
|
|
95
|
-
"ava": "^6.1.
|
|
96
|
+
"ava": "^6.1.3",
|
|
96
97
|
"eslint-config-xo-react": "^0.27.0",
|
|
97
|
-
"eslint-plugin-react": "^7.34.
|
|
98
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
99
|
-
"execa": "^
|
|
100
|
-
"nyc": "^
|
|
98
|
+
"eslint-plugin-react": "^7.34.4",
|
|
99
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
100
|
+
"execa": "^9.3.0",
|
|
101
|
+
"nyc": "^17.0.0",
|
|
101
102
|
"proxyquire": "^2.1.3",
|
|
102
103
|
"temp-write": "^5.0.0",
|
|
103
|
-
"webpack": "^5.
|
|
104
|
+
"webpack": "^5.93.0"
|
|
104
105
|
},
|
|
105
106
|
"xo": {
|
|
106
107
|
"ignores": [
|
package/readme.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
> JavaScript/TypeScript linter (ESLint wrapper) with great defaults
|
|
10
10
|
|
|
11
11
|
[](https://codecov.io/gh/xojs/xo/branch/main)
|
|
12
|
-
[](https://github.com/xojs/xo)
|
|
12
|
+
[](https://github.com/xojs/xo)
|
|
13
13
|
|
|
14
14
|
Opinionated but configurable ESLint wrapper with lots of goodies included. Enforces strict and readable code. Never discuss code style on a pull request again! No decision-making. No `.eslintrc` to manage. It just works!
|
|
15
15
|
|
|
@@ -481,10 +481,10 @@ XO is based on ESLint. This project started out as just a shareable ESLint confi
|
|
|
481
481
|
|
|
482
482
|
## Badge
|
|
483
483
|
|
|
484
|
-
Show the world you're using XO → [](https://github.com/xojs/xo)
|
|
484
|
+
Show the world you're using XO → [](https://github.com/xojs/xo)
|
|
485
485
|
|
|
486
486
|
```md
|
|
487
|
-
[](https://github.com/xojs/xo)
|
|
487
|
+
[](https://github.com/xojs/xo)
|
|
488
488
|
```
|
|
489
489
|
|
|
490
490
|
Or [customize the badge](https://github.com/xojs/xo/issues/689#issuecomment-1253127616).
|