xo 0.60.0 → 0.61.0-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/dist/cli.d.ts +56 -0
- package/dist/cli.js +209 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/lib/config.d.ts +5 -0
- package/dist/lib/config.js +395 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/constants.d.ts +16 -0
- package/dist/lib/constants.js +39 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/handle-ts-files.d.ts +15 -0
- package/dist/lib/handle-ts-files.js +68 -0
- package/dist/lib/handle-ts-files.js.map +1 -0
- package/dist/lib/open-report.d.ts +3 -0
- package/dist/lib/open-report.js +36 -0
- package/dist/lib/open-report.js.map +1 -0
- package/dist/lib/resolve-config.d.ts +9 -0
- package/dist/lib/resolve-config.js +62 -0
- package/dist/lib/resolve-config.js.map +1 -0
- package/dist/lib/types.d.ts +88 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +14 -0
- package/dist/lib/utils.js +23 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/xo-to-eslint.d.ts +11 -0
- package/dist/lib/xo-to-eslint.js +106 -0
- package/dist/lib/xo-to-eslint.js.map +1 -0
- package/dist/lib/xo.d.ts +103 -0
- package/dist/lib/xo.js +363 -0
- package/dist/lib/xo.js.map +1 -0
- package/package.json +75 -54
- package/readme.md +78 -269
- package/cli.js +0 -224
- package/config/overrides.cjs +0 -5
- package/config/plugins.cjs +0 -404
- package/index.js +0 -129
- package/lib/constants.js +0 -148
- package/lib/open-report.js +0 -45
- package/lib/options-manager.js +0 -677
- package/lib/report.js +0 -86
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
declare const cli: import("meow").Result<{
|
|
3
|
+
fix: {
|
|
4
|
+
type: "boolean";
|
|
5
|
+
default: false;
|
|
6
|
+
};
|
|
7
|
+
reporter: {
|
|
8
|
+
type: "string";
|
|
9
|
+
};
|
|
10
|
+
space: {
|
|
11
|
+
type: "string";
|
|
12
|
+
};
|
|
13
|
+
config: {
|
|
14
|
+
type: "string";
|
|
15
|
+
};
|
|
16
|
+
quiet: {
|
|
17
|
+
type: "boolean";
|
|
18
|
+
};
|
|
19
|
+
semicolon: {
|
|
20
|
+
type: "boolean";
|
|
21
|
+
};
|
|
22
|
+
prettier: {
|
|
23
|
+
type: "boolean";
|
|
24
|
+
};
|
|
25
|
+
react: {
|
|
26
|
+
type: "boolean";
|
|
27
|
+
default: false;
|
|
28
|
+
};
|
|
29
|
+
cwd: {
|
|
30
|
+
type: "string";
|
|
31
|
+
default: string;
|
|
32
|
+
};
|
|
33
|
+
printConfig: {
|
|
34
|
+
type: "string";
|
|
35
|
+
};
|
|
36
|
+
version: {
|
|
37
|
+
type: "boolean";
|
|
38
|
+
};
|
|
39
|
+
stdin: {
|
|
40
|
+
type: "boolean";
|
|
41
|
+
};
|
|
42
|
+
stdinFilename: {
|
|
43
|
+
type: "string";
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
open: {
|
|
47
|
+
type: "boolean";
|
|
48
|
+
};
|
|
49
|
+
ignore: {
|
|
50
|
+
type: "string";
|
|
51
|
+
isMultiple: true;
|
|
52
|
+
aliases: string[];
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
export type CliOptions = typeof cli;
|
|
56
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import formatterPretty from 'eslint-formatter-pretty';
|
|
6
|
+
import getStdin from 'get-stdin';
|
|
7
|
+
import meow from 'meow';
|
|
8
|
+
import { pathExists } from 'path-exists';
|
|
9
|
+
import { tsExtensions } from './lib/constants.js';
|
|
10
|
+
import { Xo } from './lib/xo.js';
|
|
11
|
+
import openReport from './lib/open-report.js';
|
|
12
|
+
const cli = meow(`
|
|
13
|
+
Usage
|
|
14
|
+
$ xo [<file|glob> ...]
|
|
15
|
+
|
|
16
|
+
Options
|
|
17
|
+
--fix Automagically fix issues
|
|
18
|
+
--reporter Reporter to use
|
|
19
|
+
--space Use space indent instead of tabs [Default: 2]
|
|
20
|
+
--semicolon Use semicolons [Default: true]
|
|
21
|
+
--prettier Conform to Prettier code style [Default: false]
|
|
22
|
+
--react Include React specific parsing and xo-react linting rules [Default: false]
|
|
23
|
+
--prettier Format with prettier or turn off prettier conflicted rules when set to 'compat' [Default: false]
|
|
24
|
+
--print-config Print the effective ESLint config for the given file
|
|
25
|
+
--open Open files with issues in your editor
|
|
26
|
+
--stdin Validate/fix code from stdin
|
|
27
|
+
--stdin-filename Specify a filename for the --stdin option
|
|
28
|
+
--ignore Ignore pattern globs, can be set multiple times
|
|
29
|
+
--cwd=<dir> Working directory for files [Default: process.cwd()]
|
|
30
|
+
|
|
31
|
+
Examples
|
|
32
|
+
$ xo
|
|
33
|
+
$ xo index.js
|
|
34
|
+
$ xo *.js !foo.js
|
|
35
|
+
$ xo --space
|
|
36
|
+
$ xo --print-config=index.js
|
|
37
|
+
`, {
|
|
38
|
+
importMeta: import.meta,
|
|
39
|
+
autoVersion: false,
|
|
40
|
+
booleanDefault: undefined,
|
|
41
|
+
flags: {
|
|
42
|
+
fix: {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
reporter: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
},
|
|
49
|
+
space: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
},
|
|
52
|
+
config: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
},
|
|
55
|
+
quiet: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
},
|
|
58
|
+
semicolon: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
},
|
|
61
|
+
prettier: {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
},
|
|
64
|
+
react: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
cwd: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
default: process.cwd(),
|
|
71
|
+
},
|
|
72
|
+
printConfig: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
},
|
|
75
|
+
version: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
},
|
|
78
|
+
stdin: {
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
},
|
|
81
|
+
stdinFilename: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: 'stdin.js',
|
|
84
|
+
},
|
|
85
|
+
open: {
|
|
86
|
+
type: 'boolean',
|
|
87
|
+
},
|
|
88
|
+
ignore: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
isMultiple: true,
|
|
91
|
+
aliases: ['ignores'],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const { input, flags: cliOptions, showVersion } = cli;
|
|
96
|
+
const baseXoConfigOptions = {
|
|
97
|
+
space: cliOptions.space,
|
|
98
|
+
semicolon: cliOptions.semicolon,
|
|
99
|
+
prettier: cliOptions.prettier,
|
|
100
|
+
ignores: cliOptions.ignore,
|
|
101
|
+
react: cliOptions.react,
|
|
102
|
+
};
|
|
103
|
+
const linterOptions = {
|
|
104
|
+
fix: cliOptions.fix,
|
|
105
|
+
cwd: (cliOptions.cwd && path.resolve(cliOptions.cwd)) ?? process.cwd(),
|
|
106
|
+
quiet: cliOptions.quiet,
|
|
107
|
+
ts: true,
|
|
108
|
+
};
|
|
109
|
+
// Make data types for `options.space` match those of the API
|
|
110
|
+
if (typeof cliOptions.space === 'string') {
|
|
111
|
+
cliOptions.space = cliOptions.space.trim();
|
|
112
|
+
if (/^\d+$/u.test(cliOptions.space)) {
|
|
113
|
+
baseXoConfigOptions.space = Number.parseInt(cliOptions.space, 10);
|
|
114
|
+
}
|
|
115
|
+
else if (cliOptions.space === 'true') {
|
|
116
|
+
baseXoConfigOptions.space = true;
|
|
117
|
+
}
|
|
118
|
+
else if (cliOptions.space === 'false') {
|
|
119
|
+
baseXoConfigOptions.space = false;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
if (cliOptions.space !== '') {
|
|
123
|
+
// Assume `options.space` was set to a filename when run as `xo --space file.js`
|
|
124
|
+
input.push(cliOptions.space);
|
|
125
|
+
}
|
|
126
|
+
baseXoConfigOptions.space = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (process.env['GITHUB_ACTIONS']
|
|
130
|
+
&& !linterOptions.fix
|
|
131
|
+
&& !cliOptions.reporter) {
|
|
132
|
+
linterOptions.quiet = true;
|
|
133
|
+
}
|
|
134
|
+
const log = async (report) => {
|
|
135
|
+
const reporter = cliOptions.reporter
|
|
136
|
+
? await new Xo(linterOptions, baseXoConfigOptions).getFormatter(cliOptions.reporter)
|
|
137
|
+
: { format: formatterPretty };
|
|
138
|
+
// @ts-expect-error the types don't quite match up here
|
|
139
|
+
console.log(reporter.format(report.results, { cwd: linterOptions.cwd, ...report }));
|
|
140
|
+
process.exitCode = report.errorCount === 0 ? 0 : 1;
|
|
141
|
+
};
|
|
142
|
+
if (cliOptions.version) {
|
|
143
|
+
showVersion();
|
|
144
|
+
}
|
|
145
|
+
if (cliOptions.stdin) {
|
|
146
|
+
const stdin = await getStdin();
|
|
147
|
+
let shouldRemoveStdInFile = false;
|
|
148
|
+
// For TypeScript, we need a file on the filesystem to lint it or else @typescript-eslint will blow up.
|
|
149
|
+
// We create a temporary file in the node_modules/.cache/xo-linter directory to avoid conflicts with the user's files and lint that file as if it were the stdin input as a work around.
|
|
150
|
+
// We clean up the file after linting.
|
|
151
|
+
if (cliOptions.stdinFilename && tsExtensions.includes(path.extname(cliOptions.stdinFilename).slice(1))) {
|
|
152
|
+
const absoluteFilePath = path.resolve(cliOptions.cwd, cliOptions.stdinFilename);
|
|
153
|
+
if (!await pathExists(absoluteFilePath)) {
|
|
154
|
+
cliOptions.stdinFilename = path.join(cliOptions.cwd, 'node_modules', '.cache', 'xo-linter', path.basename(absoluteFilePath));
|
|
155
|
+
shouldRemoveStdInFile = true;
|
|
156
|
+
baseXoConfigOptions.ignores = [
|
|
157
|
+
'!**/node_modules/**',
|
|
158
|
+
'!node_modules/**',
|
|
159
|
+
'!node_modules/',
|
|
160
|
+
`!${path.relative(cliOptions.cwd, cliOptions.stdinFilename)}`,
|
|
161
|
+
];
|
|
162
|
+
if (!await pathExists(path.dirname(cliOptions.stdinFilename))) {
|
|
163
|
+
await fs.mkdir(path.dirname(cliOptions.stdinFilename), { recursive: true });
|
|
164
|
+
}
|
|
165
|
+
await fs.writeFile(cliOptions.stdinFilename, stdin);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (cliOptions.fix) {
|
|
169
|
+
const xo = new Xo(linterOptions, baseXoConfigOptions);
|
|
170
|
+
const { results: [result] } = await xo.lintText(stdin, {
|
|
171
|
+
filePath: cliOptions.stdinFilename,
|
|
172
|
+
});
|
|
173
|
+
process.stdout.write((result?.output) ?? stdin);
|
|
174
|
+
process.exit(0);
|
|
175
|
+
}
|
|
176
|
+
if (cliOptions.open) {
|
|
177
|
+
console.error('The `--open` flag is not supported on stdin');
|
|
178
|
+
if (shouldRemoveStdInFile) {
|
|
179
|
+
await fs.rm(cliOptions.stdinFilename);
|
|
180
|
+
}
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
const xo = new Xo(linterOptions, baseXoConfigOptions);
|
|
184
|
+
await log(await xo.lintText(stdin, { filePath: cliOptions.stdinFilename, warnIgnored: true }));
|
|
185
|
+
if (shouldRemoveStdInFile) {
|
|
186
|
+
await fs.rm(cliOptions.stdinFilename);
|
|
187
|
+
}
|
|
188
|
+
process.exit(0);
|
|
189
|
+
}
|
|
190
|
+
if (typeof cliOptions.printConfig === 'string') {
|
|
191
|
+
if (input.length > 0 || cliOptions.printConfig === '') {
|
|
192
|
+
console.error('The `--print-config` flag must be used with exactly one filename');
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
const config = await new Xo(linterOptions, baseXoConfigOptions).calculateConfigForFile(cliOptions.printConfig);
|
|
196
|
+
console.log(JSON.stringify(config, undefined, '\t'));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
const xo = new Xo(linterOptions, baseXoConfigOptions);
|
|
200
|
+
const report = await xo.lintFiles(input);
|
|
201
|
+
if (cliOptions.fix) {
|
|
202
|
+
await Xo.outputFixes(report);
|
|
203
|
+
}
|
|
204
|
+
if (cliOptions.open) {
|
|
205
|
+
await openReport(report);
|
|
206
|
+
}
|
|
207
|
+
await log(report);
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import pluginAva from 'eslint-plugin-ava';
|
|
2
|
+
import pluginUnicorn from 'eslint-plugin-unicorn';
|
|
3
|
+
import pluginImport from 'eslint-plugin-import-x';
|
|
4
|
+
import pluginN from 'eslint-plugin-n';
|
|
5
|
+
import pluginComments from '@eslint-community/eslint-plugin-eslint-comments';
|
|
6
|
+
import pluginPromise from 'eslint-plugin-promise';
|
|
7
|
+
import pluginNoUseExtendNative from 'eslint-plugin-no-use-extend-native';
|
|
8
|
+
import configXoTypescript from 'eslint-config-xo-typescript';
|
|
9
|
+
import stylisticPlugin from '@stylistic/eslint-plugin';
|
|
10
|
+
import globals from 'globals';
|
|
11
|
+
import { defaultIgnores, tsExtensions, tsFilesGlob, allFilesGlob, jsExtensions, allExtensions, } from './constants.js';
|
|
12
|
+
if (Array.isArray(pluginAva?.configs?.['recommended'])) {
|
|
13
|
+
throw new TypeError('Invalid eslint-plugin-ava');
|
|
14
|
+
}
|
|
15
|
+
if (!configXoTypescript[1]) {
|
|
16
|
+
throw new Error('Invalid eslint-config-xo-typescript');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
The base config that XO builds on top of from user options.
|
|
20
|
+
*/
|
|
21
|
+
export const config = [
|
|
22
|
+
{
|
|
23
|
+
name: 'XO Default Ignores',
|
|
24
|
+
ignores: defaultIgnores,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'XO',
|
|
28
|
+
files: [
|
|
29
|
+
allFilesGlob,
|
|
30
|
+
],
|
|
31
|
+
plugins: {
|
|
32
|
+
'no-use-extend-native': pluginNoUseExtendNative,
|
|
33
|
+
ava: pluginAva,
|
|
34
|
+
unicorn: pluginUnicorn,
|
|
35
|
+
'import-x': pluginImport,
|
|
36
|
+
n: pluginN,
|
|
37
|
+
'@eslint-community/eslint-comments': pluginComments,
|
|
38
|
+
promise: pluginPromise,
|
|
39
|
+
'@stylistic': stylisticPlugin, // eslint-disable-line @typescript-eslint/naming-convention
|
|
40
|
+
},
|
|
41
|
+
languageOptions: {
|
|
42
|
+
globals: {
|
|
43
|
+
...globals.es2021,
|
|
44
|
+
...globals.node,
|
|
45
|
+
},
|
|
46
|
+
ecmaVersion: configXoTypescript[0]?.languageOptions?.ecmaVersion,
|
|
47
|
+
sourceType: configXoTypescript[0]?.languageOptions?.sourceType,
|
|
48
|
+
parserOptions: {
|
|
49
|
+
...configXoTypescript[0]?.languageOptions?.parserOptions,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
settings: {
|
|
53
|
+
'import-x/extensions': allExtensions,
|
|
54
|
+
'import-x/core-modules': [
|
|
55
|
+
'electron',
|
|
56
|
+
'atom',
|
|
57
|
+
],
|
|
58
|
+
'import-x/parsers': {
|
|
59
|
+
espree: jsExtensions,
|
|
60
|
+
'@typescript-eslint/parser': tsExtensions,
|
|
61
|
+
},
|
|
62
|
+
'import-x/external-module-folders': [
|
|
63
|
+
'node_modules',
|
|
64
|
+
'node_modules/@types',
|
|
65
|
+
],
|
|
66
|
+
'import-x/resolver': {
|
|
67
|
+
node: allExtensions,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
These are the base rules that are always applied to all js and ts file types
|
|
72
|
+
*/
|
|
73
|
+
rules: {
|
|
74
|
+
...pluginAva?.configs?.['recommended']?.rules,
|
|
75
|
+
...pluginUnicorn.configs?.recommended?.rules,
|
|
76
|
+
'no-use-extend-native/no-use-extend-native': 'error',
|
|
77
|
+
// TODO: Remove this override at some point.
|
|
78
|
+
// It's just here to ease users into readable variable names.
|
|
79
|
+
'unicorn/prevent-abbreviations': [
|
|
80
|
+
'error',
|
|
81
|
+
{
|
|
82
|
+
checkFilenames: false,
|
|
83
|
+
checkDefaultAndNamespaceImports: false,
|
|
84
|
+
checkShorthandImports: false,
|
|
85
|
+
extendDefaultReplacements: false,
|
|
86
|
+
replacements: {
|
|
87
|
+
// https://thenextweb.com/dd/2020/07/13/linux-kernel-will-no-longer-use-terms-blacklist-and-slave/
|
|
88
|
+
whitelist: {
|
|
89
|
+
include: true,
|
|
90
|
+
},
|
|
91
|
+
blacklist: {
|
|
92
|
+
exclude: true,
|
|
93
|
+
},
|
|
94
|
+
master: {
|
|
95
|
+
main: true,
|
|
96
|
+
},
|
|
97
|
+
slave: {
|
|
98
|
+
secondary: true,
|
|
99
|
+
},
|
|
100
|
+
// Not part of `eslint-plugin-unicorn`
|
|
101
|
+
application: {
|
|
102
|
+
app: true,
|
|
103
|
+
},
|
|
104
|
+
applications: {
|
|
105
|
+
apps: true,
|
|
106
|
+
},
|
|
107
|
+
// Part of `eslint-plugin-unicorn`
|
|
108
|
+
arr: {
|
|
109
|
+
array: true,
|
|
110
|
+
},
|
|
111
|
+
e: {
|
|
112
|
+
error: true,
|
|
113
|
+
event: true,
|
|
114
|
+
},
|
|
115
|
+
el: {
|
|
116
|
+
element: true,
|
|
117
|
+
},
|
|
118
|
+
elem: {
|
|
119
|
+
element: true,
|
|
120
|
+
},
|
|
121
|
+
len: {
|
|
122
|
+
length: true,
|
|
123
|
+
},
|
|
124
|
+
msg: {
|
|
125
|
+
message: true,
|
|
126
|
+
},
|
|
127
|
+
num: {
|
|
128
|
+
number: true,
|
|
129
|
+
},
|
|
130
|
+
obj: {
|
|
131
|
+
object: true,
|
|
132
|
+
},
|
|
133
|
+
opts: {
|
|
134
|
+
options: true,
|
|
135
|
+
},
|
|
136
|
+
param: {
|
|
137
|
+
parameter: true,
|
|
138
|
+
},
|
|
139
|
+
params: {
|
|
140
|
+
parameters: true,
|
|
141
|
+
},
|
|
142
|
+
prev: {
|
|
143
|
+
previous: true,
|
|
144
|
+
},
|
|
145
|
+
req: {
|
|
146
|
+
request: true,
|
|
147
|
+
},
|
|
148
|
+
res: {
|
|
149
|
+
response: true,
|
|
150
|
+
result: true,
|
|
151
|
+
},
|
|
152
|
+
ret: {
|
|
153
|
+
returnValue: true,
|
|
154
|
+
},
|
|
155
|
+
str: {
|
|
156
|
+
string: true,
|
|
157
|
+
},
|
|
158
|
+
temp: {
|
|
159
|
+
temporary: true,
|
|
160
|
+
},
|
|
161
|
+
tmp: {
|
|
162
|
+
temporary: true,
|
|
163
|
+
},
|
|
164
|
+
val: {
|
|
165
|
+
value: true,
|
|
166
|
+
},
|
|
167
|
+
err: {
|
|
168
|
+
error: true,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
// TODO: Restore when it becomes safer: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/681
|
|
174
|
+
// 'unicorn/string-content': [
|
|
175
|
+
// 'error',
|
|
176
|
+
// {
|
|
177
|
+
// patterns: {
|
|
178
|
+
// '': '’',
|
|
179
|
+
// [/\.\.\./.source]: '…',
|
|
180
|
+
// '->': '→',
|
|
181
|
+
// [/^http:\/\//.source]: 'http://'
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
184
|
+
// ],
|
|
185
|
+
// The character class sorting is a bit buggy at the moment.
|
|
186
|
+
'unicorn/better-regex': [
|
|
187
|
+
'error',
|
|
188
|
+
{
|
|
189
|
+
sortCharacterClasses: false,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
// TODO: Disabled for now until it becomes more stable: https://github.com/sindresorhus/eslint-plugin-unicorn/search?q=consistent-destructuring+is:issue&state=open&type=issues
|
|
193
|
+
'unicorn/consistent-destructuring': 'off',
|
|
194
|
+
// 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.
|
|
195
|
+
'unicorn/no-null': 'off',
|
|
196
|
+
// We only enforce it for single-line statements to not be too opinionated.
|
|
197
|
+
'unicorn/prefer-ternary': ['error', 'only-single-line'],
|
|
198
|
+
// It will be disabled in the next version of eslint-plugin-unicorn.
|
|
199
|
+
'unicorn/prefer-json-parse-buffer': 'off',
|
|
200
|
+
// TODO: Remove this override when the rule is more stable.
|
|
201
|
+
'unicorn/consistent-function-scoping': 'off',
|
|
202
|
+
// TODO: Temporarily disabled until it becomes more mature.
|
|
203
|
+
'unicorn/no-useless-undefined': 'off',
|
|
204
|
+
// TODO: Temporarily disabled as the rule is buggy.
|
|
205
|
+
'function-call-argument-newline': 'off',
|
|
206
|
+
'promise/param-names': 'error',
|
|
207
|
+
'promise/no-return-wrap': [
|
|
208
|
+
'error',
|
|
209
|
+
{
|
|
210
|
+
allowReject: true,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
'promise/no-new-statics': 'error',
|
|
214
|
+
'promise/no-return-in-finally': 'error',
|
|
215
|
+
'promise/prefer-await-to-then': [
|
|
216
|
+
'error',
|
|
217
|
+
{
|
|
218
|
+
strict: true,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
'promise/prefer-catch': 'error',
|
|
222
|
+
'promise/valid-params': 'error',
|
|
223
|
+
'import-x/default': 'error',
|
|
224
|
+
'import-x/export': 'error',
|
|
225
|
+
'import-x/extensions': [
|
|
226
|
+
'error',
|
|
227
|
+
'always',
|
|
228
|
+
{
|
|
229
|
+
ignorePackages: true,
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
'import-x/first': 'error',
|
|
233
|
+
// Enabled, but disabled on TypeScript (https://github.com/xojs/xo/issues/576)
|
|
234
|
+
'import-x/named': 'error',
|
|
235
|
+
'import-x/namespace': [
|
|
236
|
+
'error',
|
|
237
|
+
{
|
|
238
|
+
allowComputed: true,
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
'import-x/no-absolute-path': 'error',
|
|
242
|
+
'import-x/no-anonymous-default-export': 'error',
|
|
243
|
+
'import-x/no-named-default': 'error',
|
|
244
|
+
'import-x/no-webpack-loader-syntax': 'error',
|
|
245
|
+
'import-x/no-self-import': 'error',
|
|
246
|
+
'import-x/no-cycle': [
|
|
247
|
+
'error',
|
|
248
|
+
{
|
|
249
|
+
ignoreExternal: true,
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
'import-x/no-useless-path-segments': 'error',
|
|
253
|
+
'import-x/newline-after-import': [
|
|
254
|
+
'error',
|
|
255
|
+
{
|
|
256
|
+
// TODO: Buggy.
|
|
257
|
+
// considerComments: true,
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
'import-x/no-amd': 'error',
|
|
261
|
+
'import-x/no-duplicates': [
|
|
262
|
+
'error',
|
|
263
|
+
{
|
|
264
|
+
'prefer-inline': true,
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
// We use `unicorn/prefer-module` instead.
|
|
268
|
+
// 'import-x/no-commonjs': 'error',
|
|
269
|
+
// Looks useful, but too unstable at the moment
|
|
270
|
+
// 'import-x/no-deprecated': 'error',
|
|
271
|
+
'import-x/no-empty-named-blocks': 'error',
|
|
272
|
+
'import-x/no-extraneous-dependencies': [
|
|
273
|
+
'error',
|
|
274
|
+
{
|
|
275
|
+
includeTypes: true,
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
'import-x/no-mutable-exports': 'error',
|
|
279
|
+
'import-x/no-named-as-default-member': 'error',
|
|
280
|
+
'import-x/no-named-as-default': 'error',
|
|
281
|
+
// Disabled because it's buggy and it also doesn't work with TypeScript
|
|
282
|
+
// 'import-x/no-unresolved': [
|
|
283
|
+
// 'error',
|
|
284
|
+
// {
|
|
285
|
+
// commonjs: false
|
|
286
|
+
// }
|
|
287
|
+
// ],
|
|
288
|
+
'import-x/order': [
|
|
289
|
+
'error',
|
|
290
|
+
{
|
|
291
|
+
groups: ['builtin', 'external', 'parent', 'sibling', 'index'],
|
|
292
|
+
'newlines-between': 'never',
|
|
293
|
+
warnOnUnassignedImports: true,
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
'import-x/no-unassigned-import': [
|
|
297
|
+
'error',
|
|
298
|
+
{
|
|
299
|
+
allow: [
|
|
300
|
+
'@babel/polyfill',
|
|
301
|
+
'**/register',
|
|
302
|
+
'**/register.*',
|
|
303
|
+
'**/register/**',
|
|
304
|
+
'**/register/**.*',
|
|
305
|
+
'**/*.css',
|
|
306
|
+
'**/*.scss',
|
|
307
|
+
'**/*.sass',
|
|
308
|
+
'**/*.less',
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
// Redundant with `import-x/no-extraneous-dependencies`.
|
|
313
|
+
'n/no-extraneous-import': 'error',
|
|
314
|
+
// 'n/no-extraneous-require': 'error',
|
|
315
|
+
// Redundant with `import-x/no-unresolved`.
|
|
316
|
+
// 'n/no-missing-import': 'error', // This rule is also buggy and doesn't support `node:`.
|
|
317
|
+
// 'n/no-missing-require': 'error',
|
|
318
|
+
'n/no-unpublished-bin': 'error',
|
|
319
|
+
// We have this enabled in addition to `import-x/extensions` as this one has an auto-fix.
|
|
320
|
+
'n/file-extension-in-import': [
|
|
321
|
+
'error',
|
|
322
|
+
'always',
|
|
323
|
+
{
|
|
324
|
+
// TypeScript doesn't yet support using extensions and fails with error TS2691.
|
|
325
|
+
'.ts': 'never', // eslint-disable-line @typescript-eslint/naming-convention
|
|
326
|
+
'.tsx': 'never', // eslint-disable-line @typescript-eslint/naming-convention
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
'n/no-mixed-requires': [
|
|
330
|
+
'error',
|
|
331
|
+
{
|
|
332
|
+
grouping: true,
|
|
333
|
+
allowCall: true,
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
'n/no-new-require': 'error',
|
|
337
|
+
'n/no-path-concat': 'error',
|
|
338
|
+
'n/process-exit-as-throw': 'error',
|
|
339
|
+
'n/no-deprecated-api': 'error',
|
|
340
|
+
'n/prefer-global/buffer': ['error', 'never'],
|
|
341
|
+
'n/prefer-global/console': ['error', 'always'],
|
|
342
|
+
'n/prefer-global/process': ['error', 'never'],
|
|
343
|
+
'n/prefer-global/text-decoder': ['error', 'always'],
|
|
344
|
+
'n/prefer-global/text-encoder': ['error', 'always'],
|
|
345
|
+
'n/prefer-global/url-search-params': ['error', 'always'],
|
|
346
|
+
'n/prefer-global/url': ['error', 'always'],
|
|
347
|
+
'n/prefer-promises/dns': 'error',
|
|
348
|
+
'n/prefer-promises/fs': 'error',
|
|
349
|
+
'@eslint-community/eslint-comments/disable-enable-pair': [
|
|
350
|
+
'error',
|
|
351
|
+
{
|
|
352
|
+
allowWholeFile: true,
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
'@eslint-community/eslint-comments/no-aggregating-enable': 'error',
|
|
356
|
+
'@eslint-community/eslint-comments/no-duplicate-disable': 'error',
|
|
357
|
+
// Disabled as it's already covered by the `unicorn/no-abusive-eslint-disable` rule.
|
|
358
|
+
// 'eslint-comments/no-unlimited-disable': 'error',
|
|
359
|
+
'@eslint-community/eslint-comments/no-unused-disable': 'error',
|
|
360
|
+
'@eslint-community/eslint-comments/no-unused-enable': 'error',
|
|
361
|
+
...configXoTypescript[0]?.rules,
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
name: 'Xo TypeScript',
|
|
366
|
+
plugins: configXoTypescript[1]?.plugins,
|
|
367
|
+
files: [tsFilesGlob],
|
|
368
|
+
languageOptions: {
|
|
369
|
+
...configXoTypescript[1]?.languageOptions,
|
|
370
|
+
},
|
|
371
|
+
/**
|
|
372
|
+
This turns on rules in `typescript-eslint`` and turns off rules from ESLint that conflict.
|
|
373
|
+
*/
|
|
374
|
+
rules: {
|
|
375
|
+
...configXoTypescript[1]?.rules,
|
|
376
|
+
'unicorn/import-style': 'off',
|
|
377
|
+
'n/file-extension-in-import': 'off',
|
|
378
|
+
// Disabled because of https://github.com/benmosher/eslint-plugin-import-x/issues/1590
|
|
379
|
+
'import-x/export': 'off',
|
|
380
|
+
// Does not work when the TS definition exports a default const.
|
|
381
|
+
'import-x/default': 'off',
|
|
382
|
+
// Disabled as it doesn't work with TypeScript.
|
|
383
|
+
// This issue and some others: https://github.com/benmosher/eslint-plugin-import-x/issues/1341
|
|
384
|
+
'import-x/named': 'off',
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
...configXoTypescript.slice(2),
|
|
388
|
+
{
|
|
389
|
+
files: ['xo.config.{js,ts}'],
|
|
390
|
+
rules: {
|
|
391
|
+
'import-x/no-anonymous-default-export': 'off',
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
];
|
|
395
|
+
//# sourceMappingURL=config.js.map
|