xo 0.59.0 → 0.59.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/lib/options-manager.js +18 -18
- package/package.json +1 -1
package/lib/options-manager.js
CHANGED
|
@@ -116,8 +116,8 @@ const mergeWithFileConfig = async options => {
|
|
|
116
116
|
const {config: enginesOptions} = (await packageConfigExplorer.search(searchPath)) || {};
|
|
117
117
|
|
|
118
118
|
options = normalizeOptions({
|
|
119
|
-
...xoOptions,
|
|
120
119
|
...(enginesOptions && enginesOptions.node && semver.validRange(enginesOptions.node) ? {nodeVersion: enginesOptions.node} : {}),
|
|
120
|
+
...xoOptions,
|
|
121
121
|
...options,
|
|
122
122
|
});
|
|
123
123
|
options.extensions = [...DEFAULT_EXTENSION, ...(options.extensions || [])];
|
|
@@ -348,58 +348,58 @@ const buildXOConfig = options => config => {
|
|
|
348
348
|
for (const [rule, ruleConfig] of Object.entries(ENGINE_RULES)) {
|
|
349
349
|
for (const minVersion of Object.keys(ruleConfig).sort(semver.rcompare)) {
|
|
350
350
|
if (!options.nodeVersion || semver.intersects(options.nodeVersion, `<${minVersion}`)) {
|
|
351
|
-
config.baseConfig.rules[rule]
|
|
351
|
+
config.baseConfig.rules[rule] ??= ruleConfig[minVersion];
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
if (options.nodeVersion) {
|
|
357
|
-
config.baseConfig.rules['n/no-unsupported-features/es-builtins']
|
|
358
|
-
config.baseConfig.rules['n/no-unsupported-features/es-syntax']
|
|
359
|
-
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}];
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
if (options.space && !options.prettier) {
|
|
363
363
|
if (options.ts) {
|
|
364
|
-
config.baseConfig.rules['@typescript-eslint/indent']
|
|
364
|
+
config.baseConfig.rules['@typescript-eslint/indent'] ??= ['error', spaces, {SwitchCase: 1}];
|
|
365
365
|
} else {
|
|
366
|
-
config.baseConfig.rules.indent
|
|
366
|
+
config.baseConfig.rules.indent ??= ['error', spaces, {SwitchCase: 1}];
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
// Only apply if the user has the React plugin
|
|
370
370
|
if (options.cwd && resolveFrom.silent('eslint-plugin-react', options.cwd)) {
|
|
371
371
|
config.baseConfig.plugins.push('react');
|
|
372
|
-
config.baseConfig.rules['react/jsx-indent-props']
|
|
373
|
-
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];
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
if (options.semicolon === false && !options.prettier) {
|
|
378
378
|
if (options.ts) {
|
|
379
|
-
config.baseConfig.rules['@typescript-eslint/semi']
|
|
379
|
+
config.baseConfig.rules['@typescript-eslint/semi'] ??= ['error', 'never'];
|
|
380
380
|
} else {
|
|
381
|
-
config.baseConfig.rules.semi
|
|
381
|
+
config.baseConfig.rules.semi ??= ['error', 'never'];
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
config.baseConfig.rules['semi-spacing']
|
|
384
|
+
config.baseConfig.rules['semi-spacing'] ??= ['error', {
|
|
385
385
|
before: false,
|
|
386
386
|
after: true,
|
|
387
387
|
}];
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
if (options.ts) {
|
|
391
|
-
config.baseConfig.rules['unicorn/import-style']
|
|
392
|
-
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';
|
|
393
393
|
|
|
394
394
|
// Disabled because of https://github.com/benmosher/eslint-plugin-import/issues/1590
|
|
395
|
-
config.baseConfig.rules['import/export']
|
|
395
|
+
config.baseConfig.rules['import/export'] ??= 'off';
|
|
396
396
|
|
|
397
397
|
// Does not work when the TS definition exports a default const.
|
|
398
|
-
config.baseConfig.rules['import/default']
|
|
398
|
+
config.baseConfig.rules['import/default'] ??= 'off';
|
|
399
399
|
|
|
400
400
|
// Disabled as it doesn't work with TypeScript.
|
|
401
401
|
// This issue and some others: https://github.com/benmosher/eslint-plugin-import/issues/1341
|
|
402
|
-
config.baseConfig.rules['import/named']
|
|
402
|
+
config.baseConfig.rules['import/named'] ??= 'off';
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
config.baseConfig.settings['import/resolver'] = gatherImportResolvers(options);
|
|
@@ -444,7 +444,7 @@ const buildPrettierConfig = (options, prettierConfig) => config => {
|
|
|
444
444
|
config.baseConfig.extends.push('plugin:prettier/recommended');
|
|
445
445
|
|
|
446
446
|
// The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
|
|
447
|
-
config.baseConfig.rules['prettier/prettier']
|
|
447
|
+
config.baseConfig.rules['prettier/prettier'] ??= ['error', mergeWithPrettierConfig(options, prettierConfig)];
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
return config;
|