xo 0.55.1 → 0.57.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/config/plugins.cjs +63 -54
- package/index.js +3 -1
- package/lib/constants.js +3 -0
- package/lib/options-manager.js +8 -10
- package/package.json +31 -30
- package/readme.md +10 -8
package/config/plugins.cjs
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
checkFilenames: false,
|
|
42
42
|
checkDefaultAndNamespaceImports: false,
|
|
43
43
|
checkShorthandImports: false,
|
|
44
|
-
extendDefaultReplacements:
|
|
44
|
+
extendDefaultReplacements: true,
|
|
45
45
|
replacements: {
|
|
46
46
|
// https://thenextweb.com/dd/2020/07/13/linux-kernel-will-no-longer-use-terms-blacklist-and-slave/
|
|
47
47
|
whitelist: {
|
|
@@ -57,7 +57,7 @@ module.exports = {
|
|
|
57
57
|
secondary: true,
|
|
58
58
|
},
|
|
59
59
|
|
|
60
|
-
//
|
|
60
|
+
// Reverse.
|
|
61
61
|
application: {
|
|
62
62
|
app: true,
|
|
63
63
|
},
|
|
@@ -65,68 +65,75 @@ module.exports = {
|
|
|
65
65
|
apps: true,
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// Disable some that may be too annoying.
|
|
69
|
+
env: false,
|
|
70
|
+
i: false, // Do it at some point, but not ready for it yet. Maybe 2025.
|
|
71
|
+
|
|
72
|
+
// Not part of `eslint-plugin-unicorn`. Upstream them at some point.
|
|
73
|
+
bin: {
|
|
74
|
+
binary: true,
|
|
71
75
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
event: true,
|
|
76
|
+
eof: {
|
|
77
|
+
endOfFile: true,
|
|
75
78
|
},
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
impl: {
|
|
80
|
+
implement: true,
|
|
81
|
+
implementation: true,
|
|
78
82
|
},
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
anim: {
|
|
84
|
+
animation: true,
|
|
81
85
|
},
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
calc: {
|
|
87
|
+
calculate: true,
|
|
84
88
|
},
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
dict: {
|
|
90
|
+
dictionary: true,
|
|
87
91
|
},
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
dup: {
|
|
93
|
+
duplicate: true,
|
|
90
94
|
},
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
enc: {
|
|
96
|
+
encode: true,
|
|
97
|
+
encryption: true,
|
|
93
98
|
},
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
gen: {
|
|
100
|
+
generate: true,
|
|
101
|
+
general: true,
|
|
96
102
|
},
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
gfx: {
|
|
104
|
+
graphics: true,
|
|
99
105
|
},
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
inc: {
|
|
107
|
+
increment: true,
|
|
102
108
|
},
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
iter: {
|
|
110
|
+
iterate: true,
|
|
111
|
+
iterator: true,
|
|
105
112
|
},
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
nav: {
|
|
114
|
+
navigate: true,
|
|
115
|
+
navigation: true,
|
|
108
116
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
result: true,
|
|
117
|
+
norm: {
|
|
118
|
+
normalize: true,
|
|
112
119
|
},
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
notif: {
|
|
121
|
+
notification: true,
|
|
115
122
|
},
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
perf: {
|
|
124
|
+
performance: true,
|
|
118
125
|
},
|
|
119
|
-
|
|
120
|
-
|
|
126
|
+
proc: {
|
|
127
|
+
process: true,
|
|
121
128
|
},
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
rand: {
|
|
130
|
+
random: true,
|
|
124
131
|
},
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
sys: {
|
|
133
|
+
system: true,
|
|
127
134
|
},
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
temp: {
|
|
136
|
+
temporary: true,
|
|
130
137
|
},
|
|
131
138
|
},
|
|
132
139
|
},
|
|
@@ -153,13 +160,10 @@ module.exports = {
|
|
|
153
160
|
},
|
|
154
161
|
],
|
|
155
162
|
|
|
156
|
-
// Temporarily disabled because
|
|
163
|
+
// Temporarily disabled because of https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2218
|
|
157
164
|
'unicorn/no-empty-file': 'off',
|
|
158
165
|
|
|
159
|
-
// TODO: Disabled for now
|
|
160
|
-
'unicorn/consistent-destructuring': 'off',
|
|
161
|
-
|
|
162
|
-
// TODO: Disabled for now as I don't have time to deal with the backslash that might come from this. Try to enable this rule in 2021.
|
|
166
|
+
// TODO: Disabled for now as I don't have time to deal with the backslash that might come from this. Try to enable this rule in 2025.
|
|
163
167
|
'unicorn/no-null': 'off',
|
|
164
168
|
|
|
165
169
|
// We only enforce it for single-line statements to not be too opinionated.
|
|
@@ -314,6 +318,8 @@ module.exports = {
|
|
|
314
318
|
// TypeScript doesn't yet support using extensions and fails with error TS2691.
|
|
315
319
|
'.ts': 'never',
|
|
316
320
|
'.tsx': 'never',
|
|
321
|
+
'.mts': 'never',
|
|
322
|
+
'.cts': 'never',
|
|
317
323
|
},
|
|
318
324
|
],
|
|
319
325
|
'n/no-mixed-requires': [
|
|
@@ -353,10 +359,13 @@ module.exports = {
|
|
|
353
359
|
// 'n/shebang': 'error',
|
|
354
360
|
|
|
355
361
|
'n/no-deprecated-api': 'error',
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
362
|
+
|
|
363
|
+
// We no longer enforce this as we don't want to use Buffer at all, but sometimes we need to conditionally use the `Buffer` global, but we then don't want the import so the module works cross-platform.
|
|
364
|
+
// 'n/prefer-global/buffer': [
|
|
365
|
+
// 'error',
|
|
366
|
+
// 'never',
|
|
367
|
+
// ],
|
|
368
|
+
|
|
360
369
|
'n/prefer-global/console': [
|
|
361
370
|
'error',
|
|
362
371
|
'always',
|
package/index.js
CHANGED
|
@@ -28,7 +28,9 @@ const globFiles = async (patterns, options) => {
|
|
|
28
28
|
|
|
29
29
|
const files = await globby(
|
|
30
30
|
patterns,
|
|
31
|
-
{
|
|
31
|
+
{
|
|
32
|
+
ignore: ignores, gitignore: true, absolute: true, cwd,
|
|
33
|
+
},
|
|
32
34
|
);
|
|
33
35
|
|
|
34
36
|
return files.filter(file => extensions.includes(path.extname(file).slice(1)));
|
package/lib/constants.js
CHANGED
|
@@ -7,6 +7,7 @@ const DEFAULT_IGNORES = [
|
|
|
7
7
|
'**/*.min.js',
|
|
8
8
|
'vendor/**',
|
|
9
9
|
'dist/**',
|
|
10
|
+
'distribution/**',
|
|
10
11
|
'tap-snapshots/*.{cjs,js}',
|
|
11
12
|
];
|
|
12
13
|
|
|
@@ -24,6 +25,8 @@ const MERGE_OPTIONS_CONCAT = [
|
|
|
24
25
|
const TYPESCRIPT_EXTENSION = [
|
|
25
26
|
'ts',
|
|
26
27
|
'tsx',
|
|
28
|
+
'mts',
|
|
29
|
+
'cts',
|
|
27
30
|
];
|
|
28
31
|
|
|
29
32
|
const DEFAULT_EXTENSION = [
|
package/lib/options-manager.js
CHANGED
|
@@ -4,7 +4,7 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import arrify from 'arrify';
|
|
6
6
|
import {mergeWith, flow, pick} from 'lodash-es';
|
|
7
|
-
import {findUpSync} from 'find-up';
|
|
7
|
+
import {findUpSync} from 'find-up-simple';
|
|
8
8
|
import findCacheDir from 'find-cache-dir';
|
|
9
9
|
import prettier from 'prettier';
|
|
10
10
|
import semver from 'semver';
|
|
@@ -83,7 +83,7 @@ const getEmptyXOConfig = () => ({
|
|
|
83
83
|
extends: [],
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
const
|
|
86
|
+
const mergeFunction = (previousValue, value, key) => {
|
|
87
87
|
if (Array.isArray(previousValue)) {
|
|
88
88
|
if (MERGE_OPTIONS_CONCAT.includes(key)) {
|
|
89
89
|
return [...previousValue, ...value];
|
|
@@ -102,14 +102,12 @@ The config files are searched starting from `options.filePath` if defined or `op
|
|
|
102
102
|
const mergeWithFileConfig = async options => {
|
|
103
103
|
options.cwd = path.resolve(options.cwd || process.cwd());
|
|
104
104
|
const configExplorer = cosmiconfig(MODULE_NAME, {searchPlaces: CONFIG_FILES, loaders: {noExt: defaultLoaders['.json']}, stopDir: options.cwd});
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
options.filePath = path.resolve(options.cwd, options.filePath);
|
|
108
|
-
}
|
|
105
|
+
const packageConfigExplorer = cosmiconfig('engines', {searchPlaces: ['package.json'], stopDir: options.cwd});
|
|
106
|
+
options.filePath &&= path.resolve(options.cwd, options.filePath);
|
|
109
107
|
|
|
110
108
|
const searchPath = options.filePath || options.cwd;
|
|
111
109
|
const {config: xoOptions, filepath: xoConfigPath} = (await configExplorer.search(searchPath)) || {};
|
|
112
|
-
const {config: enginesOptions} = (await
|
|
110
|
+
const {config: enginesOptions} = (await packageConfigExplorer.search(searchPath)) || {};
|
|
113
111
|
|
|
114
112
|
options = normalizeOptions({
|
|
115
113
|
...xoOptions,
|
|
@@ -274,7 +272,7 @@ const buildConfig = (options, prettierOptions) => {
|
|
|
274
272
|
buildTSConfig(options),
|
|
275
273
|
buildExtendsConfig(options),
|
|
276
274
|
buildPrettierConfig(options, prettierOptions),
|
|
277
|
-
)(mergeWith(getEmptyConfig(), DEFAULT_CONFIG,
|
|
275
|
+
)(mergeWith(getEmptyConfig(), DEFAULT_CONFIG, mergeFunction));
|
|
278
276
|
};
|
|
279
277
|
|
|
280
278
|
const toValueMap = (array, value = true) => Object.fromEntries(array.map(item => [item, value]));
|
|
@@ -473,7 +471,7 @@ const mergeWithPrettierConfig = (options, prettierOptions) => {
|
|
|
473
471
|
semi: options.semicolon !== false,
|
|
474
472
|
},
|
|
475
473
|
prettierOptions,
|
|
476
|
-
|
|
474
|
+
mergeFunction,
|
|
477
475
|
);
|
|
478
476
|
};
|
|
479
477
|
|
|
@@ -503,7 +501,7 @@ const applyOverrides = (file, options) => {
|
|
|
503
501
|
|
|
504
502
|
const {applicable, hash} = findApplicableOverrides(path.relative(options.cwd, file), overrides);
|
|
505
503
|
|
|
506
|
-
options = mergeWith(getEmptyXOConfig(), options, ...applicable.map(override => normalizeOptions(override)),
|
|
504
|
+
options = mergeWith(getEmptyXOConfig(), options, ...applicable.map(override => normalizeOptions(override)), mergeFunction);
|
|
507
505
|
delete options.files;
|
|
508
506
|
return {options, hash};
|
|
509
507
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "JavaScript/TypeScript linter (ESLint wrapper) with great defaults",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "xojs/xo",
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"bin": "./cli.js",
|
|
15
|
+
"sideEffects": false,
|
|
15
16
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
17
|
+
"node": ">=18"
|
|
17
18
|
},
|
|
18
19
|
"scripts": {
|
|
19
20
|
"test:clean": "find ./test -type d -name 'node_modules' -prune -not -path ./test/fixtures/project/node_modules -exec rm -rf '{}' +",
|
|
@@ -53,53 +54,53 @@
|
|
|
53
54
|
"typescript"
|
|
54
55
|
],
|
|
55
56
|
"dependencies": {
|
|
56
|
-
"@eslint/eslintrc": "^
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
58
|
-
"@typescript-eslint/parser": "^6.
|
|
57
|
+
"@eslint/eslintrc": "^3.0.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
59
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
59
60
|
"arrify": "^3.0.0",
|
|
60
|
-
"cosmiconfig": "^8.
|
|
61
|
+
"cosmiconfig": "^8.3.6",
|
|
61
62
|
"define-lazy-prop": "^3.0.0",
|
|
62
|
-
"eslint": "^8.
|
|
63
|
-
"eslint-config-prettier": "^
|
|
64
|
-
"eslint-config-xo": "^0.
|
|
65
|
-
"eslint-config-xo-typescript": "^
|
|
66
|
-
"eslint-formatter-pretty": "^
|
|
67
|
-
"eslint-import-resolver-webpack": "^0.13.
|
|
63
|
+
"eslint": "^8.53.0",
|
|
64
|
+
"eslint-config-prettier": "^9.1.0",
|
|
65
|
+
"eslint-config-xo": "^0.44.0",
|
|
66
|
+
"eslint-config-xo-typescript": "^2.0.0",
|
|
67
|
+
"eslint-formatter-pretty": "^6.0.1",
|
|
68
|
+
"eslint-import-resolver-webpack": "^0.13.8",
|
|
68
69
|
"eslint-plugin-ava": "^14.0.0",
|
|
69
70
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
70
|
-
"eslint-plugin-import": "
|
|
71
|
-
"eslint-plugin-n": "^16.
|
|
71
|
+
"eslint-plugin-import": "^2.29.1",
|
|
72
|
+
"eslint-plugin-n": "^16.6.2",
|
|
72
73
|
"eslint-plugin-no-use-extend-native": "^0.5.0",
|
|
73
|
-
"eslint-plugin-prettier": "^5.
|
|
74
|
-
"eslint-plugin-unicorn": "^
|
|
75
|
-
"esm-utils": "^4.1
|
|
76
|
-
"find-cache-dir": "^
|
|
77
|
-
"find-up": "^
|
|
74
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
75
|
+
"eslint-plugin-unicorn": "^51.0.0",
|
|
76
|
+
"esm-utils": "^4.2.1",
|
|
77
|
+
"find-cache-dir": "^5.0.0",
|
|
78
|
+
"find-up-simple": "^1.0.0",
|
|
78
79
|
"get-stdin": "^9.0.0",
|
|
79
|
-
"get-tsconfig": "^4.
|
|
80
|
-
"globby": "^
|
|
80
|
+
"get-tsconfig": "^4.7.2",
|
|
81
|
+
"globby": "^14.0.0",
|
|
81
82
|
"imurmurhash": "^0.1.4",
|
|
82
83
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
|
83
84
|
"lodash-es": "^4.17.21",
|
|
84
|
-
"meow": "^
|
|
85
|
+
"meow": "^13.1.0",
|
|
85
86
|
"micromatch": "^4.0.5",
|
|
86
|
-
"open-editor": "^4.
|
|
87
|
-
"prettier": "^3.
|
|
88
|
-
"semver": "^7.
|
|
87
|
+
"open-editor": "^4.1.1",
|
|
88
|
+
"prettier": "^3.2.5",
|
|
89
|
+
"semver": "^7.6.0",
|
|
89
90
|
"slash": "^5.1.0",
|
|
90
91
|
"to-absolute-glob": "^3.0.0",
|
|
91
|
-
"typescript": "^5.
|
|
92
|
+
"typescript": "^5.3.3"
|
|
92
93
|
},
|
|
93
94
|
"devDependencies": {
|
|
94
|
-
"ava": "^
|
|
95
|
+
"ava": "^6.1.1",
|
|
95
96
|
"eslint-config-xo-react": "^0.27.0",
|
|
96
|
-
"eslint-plugin-react": "^7.
|
|
97
|
+
"eslint-plugin-react": "^7.33.2",
|
|
97
98
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
98
|
-
"execa": "^
|
|
99
|
+
"execa": "^8.0.1",
|
|
99
100
|
"nyc": "^15.1.0",
|
|
100
101
|
"proxyquire": "^2.1.3",
|
|
101
102
|
"temp-write": "^5.0.0",
|
|
102
|
-
"webpack": "^5.
|
|
103
|
+
"webpack": "^5.90.1"
|
|
103
104
|
},
|
|
104
105
|
"xo": {
|
|
105
106
|
"ignores": [
|
package/readme.md
CHANGED
|
@@ -282,7 +282,7 @@ Use one or more [shareable configs](https://eslint.org/docs/developer-guide/shar
|
|
|
282
282
|
|
|
283
283
|
Type: `string[]`
|
|
284
284
|
|
|
285
|
-
Allow more extensions to be linted besides `.js`, `.jsx`, `.mjs`, and `.cjs`. Make sure they're supported by ESLint or an ESLint plugin.
|
|
285
|
+
Allow more extensions to be linted besides `.js`, `.jsx`, `.mjs`, and `.cjs` as well as their TypeScript equivalents `.ts`, `.tsx`, `.mts` and `.cts`. Make sure they're supported by ESLint or an ESLint plugin.
|
|
286
286
|
|
|
287
287
|
### settings
|
|
288
288
|
|
|
@@ -315,9 +315,9 @@ Setting this to an object enables the resolver and passes the object as configur
|
|
|
315
315
|
|
|
316
316
|
## TypeScript
|
|
317
317
|
|
|
318
|
-
XO will automatically lint TypeScript files (`.ts`, `.d.ts` and `.tsx`) with the rules defined in [eslint-config-xo-typescript#use-with-xo](https://github.com/xojs/eslint-config-xo-typescript#use-with-xo).
|
|
318
|
+
XO will automatically lint TypeScript files (`.ts`, `.mts`, `.cts`, `.d.ts` and `.tsx`) with the rules defined in [eslint-config-xo-typescript#use-with-xo](https://github.com/xojs/eslint-config-xo-typescript#use-with-xo).
|
|
319
319
|
|
|
320
|
-
XO will handle the [@typescript-eslint/parser `project` option](https://
|
|
320
|
+
XO will handle the [@typescript-eslint/parser `project` option](https://typescript-eslint.io/packages/parser/#project) automatically even if you don't have a `tsconfig.json` in your project.
|
|
321
321
|
|
|
322
322
|
## GitHub Actions
|
|
323
323
|
|
|
@@ -384,7 +384,7 @@ If some files in your project are transpiled in order to support an older Node.j
|
|
|
384
384
|
|
|
385
385
|
For example, if your project targets Node.js 8 but you want to use the latest JavaScript syntax as supported in Node.js 12:
|
|
386
386
|
1. Set the `engines.node` property of your `package.json` to `>=8`
|
|
387
|
-
2. Configure [Babel](https://babeljs.io) to transpile your source files (in `
|
|
387
|
+
2. Configure [Babel](https://babeljs.io) to transpile your source files (in `source` directory in this example)
|
|
388
388
|
3. Make sure to include the transpiled files in your published package with the [`files`](https://docs.npmjs.com/files/package.json#files) and [`main`](https://docs.npmjs.com/files/package.json#main) properties of your `package.json`
|
|
389
389
|
4. Configure the XO `overrides` option to set `nodeVersion` to `>=12` for your source files directory
|
|
390
390
|
|
|
@@ -394,14 +394,16 @@ For example, if your project targets Node.js 8 but you want to use the latest Ja
|
|
|
394
394
|
"node": ">=12"
|
|
395
395
|
},
|
|
396
396
|
"scripts": {
|
|
397
|
-
"build": "babel
|
|
397
|
+
"build": "babel source --out-dir distribution"
|
|
398
398
|
},
|
|
399
|
-
"main": "
|
|
400
|
-
"files": [
|
|
399
|
+
"main": "distribution/index.js",
|
|
400
|
+
"files": [
|
|
401
|
+
"distribution/**/*.js"
|
|
402
|
+
],
|
|
401
403
|
"xo": {
|
|
402
404
|
"overrides": [
|
|
403
405
|
{
|
|
404
|
-
"files": "
|
|
406
|
+
"files": "source/**/*.js",
|
|
405
407
|
"nodeVersion": ">=16"
|
|
406
408
|
}
|
|
407
409
|
]
|