eslint-config-xo 3.0.1 → 3.0.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/index.d.ts +2 -0
- package/index.js +32 -24
- package/package.json +1 -1
- package/source/rules/no-use-extend-native.js +5 -15
package/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export const jsExtensions: string[];
|
|
|
5
5
|
export const frameworkExtensions: string[];
|
|
6
6
|
export const htmlExtensions: string[];
|
|
7
7
|
export const mdExtensions: string[];
|
|
8
|
+
export const jsonExtensions: string[];
|
|
9
|
+
export const cssExtensions: string[];
|
|
8
10
|
export const allExtensions: string[];
|
|
9
11
|
|
|
10
12
|
export const tsFilesGlob: string;
|
package/index.js
CHANGED
|
@@ -38,6 +38,7 @@ try {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// TODO: Drop `cts` in the next major version, as CommonJS is no longer supported.
|
|
41
42
|
export const tsExtensions = [
|
|
42
43
|
'ts',
|
|
43
44
|
'tsx',
|
|
@@ -45,6 +46,7 @@ export const tsExtensions = [
|
|
|
45
46
|
'cts',
|
|
46
47
|
];
|
|
47
48
|
|
|
49
|
+
// TODO: Drop `cjs` in the next major version, as CommonJS is no longer supported.
|
|
48
50
|
export const jsExtensions = [
|
|
49
51
|
'js',
|
|
50
52
|
'jsx',
|
|
@@ -66,6 +68,16 @@ export const mdExtensions = [
|
|
|
66
68
|
'md',
|
|
67
69
|
];
|
|
68
70
|
|
|
71
|
+
export const jsonExtensions = [
|
|
72
|
+
'json',
|
|
73
|
+
'jsonc',
|
|
74
|
+
'json5',
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
export const cssExtensions = [
|
|
78
|
+
'css',
|
|
79
|
+
];
|
|
80
|
+
|
|
69
81
|
export const allExtensions = [
|
|
70
82
|
...jsExtensions,
|
|
71
83
|
...tsExtensions,
|
|
@@ -94,9 +106,12 @@ export const defaultIgnores = [
|
|
|
94
106
|
'coverage/**',
|
|
95
107
|
'{tmp,temp}/**',
|
|
96
108
|
'**/*.min.js',
|
|
109
|
+
'**/*.min.css',
|
|
97
110
|
'vendor/**',
|
|
98
111
|
'dist/**',
|
|
99
112
|
'tap-snapshots/*.{cjs,js}',
|
|
113
|
+
'**/package-lock.json',
|
|
114
|
+
'**/npm-shrinkwrap.json',
|
|
100
115
|
];
|
|
101
116
|
|
|
102
117
|
const pluginNoUseExtendNative = {
|
|
@@ -117,6 +132,21 @@ const missingTypeScriptParser = {
|
|
|
117
132
|
},
|
|
118
133
|
};
|
|
119
134
|
|
|
135
|
+
const missingTypeScriptConfig = {
|
|
136
|
+
name: 'xo/missing-typescript',
|
|
137
|
+
files: [
|
|
138
|
+
tsFilesGlob,
|
|
139
|
+
],
|
|
140
|
+
ignores: [
|
|
141
|
+
'**/*.d.ts',
|
|
142
|
+
'**/*.d.mts',
|
|
143
|
+
'**/*.d.cts',
|
|
144
|
+
],
|
|
145
|
+
languageOptions: {
|
|
146
|
+
parser: missingTypeScriptParser,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
120
150
|
function isMissingTypeScriptError(error) {
|
|
121
151
|
return error instanceof Error
|
|
122
152
|
&& (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'MODULE_NOT_FOUND')
|
|
@@ -136,11 +166,7 @@ function getGitignoreConfig(configUrl) {
|
|
|
136
166
|
const gitignorePath = fileURLToPath(new URL('.gitignore', configUrl));
|
|
137
167
|
|
|
138
168
|
// Skip silently when there is no `.gitignore`, so opting in never crashes.
|
|
139
|
-
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return includeIgnoreFile(gitignorePath, {name: 'xo/gitignore', gitignoreResolution: true});
|
|
169
|
+
return fs.existsSync(gitignorePath) ? includeIgnoreFile(gitignorePath, {name: 'xo/gitignore', gitignoreResolution: true}) : undefined;
|
|
144
170
|
}
|
|
145
171
|
|
|
146
172
|
function getOptionRules({
|
|
@@ -343,24 +369,6 @@ export default function eslintConfigXo({
|
|
|
343
369
|
optionRules: getOptionRules({space, semicolon, typescript: true}),
|
|
344
370
|
tsExtensions,
|
|
345
371
|
}) ?? [];
|
|
346
|
-
const missingTypeScriptConfig = [];
|
|
347
|
-
if (!ts) {
|
|
348
|
-
missingTypeScriptConfig.push({
|
|
349
|
-
name: 'xo/missing-typescript',
|
|
350
|
-
files: [
|
|
351
|
-
tsFilesGlob,
|
|
352
|
-
],
|
|
353
|
-
ignores: [
|
|
354
|
-
'**/*.d.ts',
|
|
355
|
-
'**/*.d.mts',
|
|
356
|
-
'**/*.d.cts',
|
|
357
|
-
],
|
|
358
|
-
languageOptions: {
|
|
359
|
-
parser: missingTypeScriptParser,
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
372
|
// `eslint-plugin-ava` bundles its own `@eslint/json` copy for its `**/package.json` config, which clashes with our `json` plugin registration on the same files (ESLint forbids defining the same plugin name with two different objects). Reuse our `json` instance so the references match.
|
|
365
373
|
const avaConfigs = pluginAva.configs.recommended.map(avaConfig => {
|
|
366
374
|
const namedAvaConfig = {
|
|
@@ -418,7 +426,7 @@ export default function eslintConfigXo({
|
|
|
418
426
|
}),
|
|
419
427
|
getHtmlConfig({space, prettier}),
|
|
420
428
|
getMarkdownConfig(),
|
|
421
|
-
...missingTypeScriptConfig,
|
|
429
|
+
...(ts ? [] : [missingTypeScriptConfig]),
|
|
422
430
|
|
|
423
431
|
{
|
|
424
432
|
name: 'xo/css',
|
package/package.json
CHANGED
|
@@ -211,21 +211,11 @@ const nativeObjectDefinitions = [
|
|
|
211
211
|
const nativeObjects = new Map();
|
|
212
212
|
|
|
213
213
|
for (const nativeObjectDefinition of nativeObjectDefinitions) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (nativeObjectDefinition.prototype) {
|
|
221
|
-
nativeObjectInfo.prototype = createPropertyInfo(nativeObjectDefinition.prototype);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (nativeObjectDefinition.static) {
|
|
225
|
-
nativeObjectInfo.static = createPropertyInfo(nativeObjectDefinition.static);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
nativeObjects.set(nativeObjectDefinition.typeName, nativeObjectInfo);
|
|
214
|
+
nativeObjects.set(nativeObjectDefinition.typeName, {
|
|
215
|
+
instance: nativeObjectDefinition.instance ? createPropertyInfo(nativeObjectDefinition.instance, nativeObjectDefinition.instanceProperties) : undefined,
|
|
216
|
+
prototype: nativeObjectDefinition.prototype ? createPropertyInfo(nativeObjectDefinition.prototype) : undefined,
|
|
217
|
+
static: nativeObjectDefinition.static ? createPropertyInfo(nativeObjectDefinition.static) : undefined,
|
|
218
|
+
});
|
|
229
219
|
}
|
|
230
220
|
|
|
231
221
|
const getPropertyName = memberExpression => {
|