Skip to content

Commit e80c094

Browse files
committedApr 14, 2021
Remove the esnext option
1 parent b385bee commit e80c094

File tree

19 files changed

+44
-93
lines changed

19 files changed

+44
-93
lines changed
 

Diff for: ‎cli-main.js

-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const cli = meow(`
2727
--open Open files with issues in your editor
2828
--quiet Show only errors and no warnings
2929
--extension Additional extension to lint [Can be set multiple times]
30-
--no-esnext Don't enforce ES2015+ rules
3130
--cwd=<dir> Working directory for files
3231
--stdin Validate/fix code from stdin
3332
--stdin-filename Specify a filename for the --stdin option
@@ -97,9 +96,6 @@ const cli = meow(`
9796
type: 'string',
9897
isMultiple: true
9998
},
100-
esnext: {
101-
type: 'boolean'
102-
},
10399
cwd: {
104100
type: 'string'
105101
},

Diff for: ‎lib/options-manager.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ const mergeWithFileConfigs = async (files, options, configFiles) => {
162162
([tsConfigPath, groups]) => {
163163
const files = [].concat(...groups.map(group => group.files));
164164
const cachePath = getTsConfigCachePath(files, tsConfigPath);
165-
groups.forEach(group => {
165+
166+
for (const group of groups) {
166167
group.options.tsConfigPath = cachePath;
167-
});
168+
}
169+
168170
return outputJson(cachePath, makeTSConfig(tsConfigs[tsConfigPath], tsConfigPath, files));
169171
}
170172
));
@@ -180,11 +182,11 @@ Hashing based on https://github.com/eslint/eslint/blob/cf38d0d939b62f3670cdd59f0
180182
*/
181183
const getTsConfigCachePath = (files, tsConfigPath) => path.join(
182184
cacheLocation,
183-
`tsconfig.${murmur(`${pkg.version}_${nodeVersion}_${stringify({files: files.sort(), tsConfigPath: tsConfigPath})}`).result().toString(36)}.json`
185+
`tsconfig.${murmur(`${pkg.version}_${nodeVersion}_${stringify({files: files.sort(), tsConfigPath})}`).result().toString(36)}.json`
184186
);
185187

186188
const makeTSConfig = (tsConfig, tsConfigPath, files) => {
187-
const config = {files: files.filter(isTypescript)};
189+
const config = {files: files.filter(file => isTypescript(file))};
188190

189191
if (tsConfig) {
190192
config.extends = tsConfigPath;
@@ -308,13 +310,6 @@ const buildXOConfig = options => config => {
308310
}];
309311
}
310312

311-
if (options.esnext !== false) {
312-
config.baseConfig.extends = [
313-
'xo/esnext',
314-
path.join(__dirname, '../config/plugins.js')
315-
];
316-
}
317-
318313
if (options.ts) {
319314
config.rules['unicorn/import-style'] = 'off';
320315
config.rules['node/file-extension-in-import'] = 'off';
@@ -464,7 +459,7 @@ const applyOverrides = (file, options) => {
464459
const {overrides} = options;
465460
delete options.overrides;
466461

467-
let {applicable, hash} = findApplicableOverrides(path.relative(options.cwd, file), overrides);
462+
const {applicable, hash} = findApplicableOverrides(path.relative(options.cwd, file), overrides);
468463

469464
options = mergeWith(...[getEmptyOptions(), options].concat(applicable.map(override => normalizeOptions(override)), mergeFn));
470465
delete options.files;

Diff for: ‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"debug": "^4.3.1",
5959
"eslint": "^7.20.0",
6060
"eslint-config-prettier": "^7.2.0",
61-
"eslint-config-xo": "^0.35.0",
61+
"eslint-config-xo": "^0.36.0",
6262
"eslint-config-xo-typescript": "^0.38.0",
6363
"eslint-formatter-pretty": "^4.0.0",
6464
"eslint-import-resolver-webpack": "^0.13.0",

Diff for: ‎readme.md

+3-16
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ $ xo --help
6868
--open Open files with issues in your editor
6969
--quiet Show only errors and no warnings
7070
--extension Additional extension to lint [Can be set multiple times]
71-
--no-esnext Don't enforce ES2015+ rules
7271
--cwd=<dir> Working directory for files
7372
--stdin Validate/fix code from stdin
7473
--stdin-filename Specify a filename for the --stdin option
@@ -267,15 +266,6 @@ Type: `string`
267266

268267
[ESLint processor.](https://eslint.org/docs/user-guide/configuring#specifying-processor)
269268

270-
### esnext
271-
272-
Type: `boolean`\
273-
Default: `true`
274-
275-
Enforce ES2015+ rules. Disabling this will make it not *enforce* ES2015+ syntax and conventions.
276-
277-
*ES2015+ is parsed even without this option. You can already use ES2017 features like [`async`/`await`](https://github.com/lukehoban/ecmascript-asyncawait).
278-
279269
### webpack
280270

281271
Type: `boolean | object`
@@ -317,12 +307,11 @@ XO makes it easy to override configs for specific files. The `overrides` propert
317307
"overrides": [
318308
{
319309
"files": "test/*.js",
320-
"esnext": false,
321310
"space": 3
322311
},
323312
{
324313
"files": "test/foo.js",
325-
"esnext": true
314+
"semicolon": true
326315
}
327316
]
328317
}
@@ -331,11 +320,10 @@ XO makes it easy to override configs for specific files. The `overrides` propert
331320

332321
- The base configuration is simply `space: 2`, `semicolon: false`. These settings are used for every file unless otherwise noted below.
333322

334-
- For every file in `test/*.js`, the base config is used, but `space` is overridden with `3`, and the `esnext` option is set to `false`. The resulting config is:
323+
- For every file in `test/*.js`, the base config is used, but `space` is overridden with `3`. The resulting config is:
335324

336325
```json
337326
{
338-
"esnext": false,
339327
"semicolon": false,
340328
"space": 3
341329
}
@@ -345,8 +333,7 @@ XO makes it easy to override configs for specific files. The `overrides` propert
345333

346334
```json
347335
{
348-
"esnext": true,
349-
"semicolon": false,
336+
"semicolon": true,
350337
"space": 3
351338
}
352339
```

Diff for: ‎test/fixtures/config-files/xo-config/.xo-config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"esnext": true
2+
"space": true
33
}

Diff for: ‎test/fixtures/config-files/xo-config/file.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
var obj = { a: 1 };
2-
console.log(obj.a);
1+
const object = {
2+
a: 1
3+
};
4+
5+
console.log(object.a);
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
esnext: true
3-
}
2+
space: true
3+
};

Diff for: ‎test/fixtures/config-files/xo-config_js/file.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
var obj = { a: 1 };
2-
console.log(obj.a);
1+
const object = {
2+
a: 1
3+
};
4+
5+
console.log(object.a);
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"esnext": true
2+
"space": true
33
}

Diff for: ‎test/fixtures/config-files/xo-config_json/file.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
var obj = { a: 1 };
2-
console.log(obj.a);
1+
const object = {
2+
a: 1
3+
};
4+
5+
console.log(object.a);

Diff for: ‎test/fixtures/config-files/xo_config_js/file.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
var obj = { a: 1 };
2-
console.log(obj.a);
1+
const object = {
2+
a: 1
3+
};
4+
5+
console.log(object.a);

Diff for: ‎test/fixtures/config-files/xo_config_js/xo.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
esnext: true
3-
}
2+
space: true
3+
};

Diff for: ‎test/fixtures/nested/child/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"xo": {
3-
"esnext": false
3+
"space": true
44
}
55
}

Diff for: ‎test/fixtures/nested/file.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
var obj = { a: 1 };
2-
console.log(obj.a);
1+
const object = {a: 1};
2+
console.log(object.a);

Diff for: ‎test/fixtures/nested/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"xo": {
3-
"esnext": true
3+
"space": true
44
}
55
}

Diff for: ‎test/fixtures/overrides/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"overrides": [
66
{
77
"files": "test/*.js",
8-
"esnext": true,
98
"space": 3
109
},
1110
{

Diff for: ‎test/lint-files.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ test('typescript files', async t => {
197197
});
198198

199199
test('typescript 2 space option', async t => {
200-
const {errorCount} = await fn.lintFiles('two-spaces.tsx', {cwd: 'fixtures/typescript', space: 2});
201-
t.is(errorCount, 0);
200+
const {errorCount, results} = await fn.lintFiles('two-spaces.tsx', {cwd: 'fixtures/typescript', space: 2});
201+
t.is(errorCount, 0, JSON.stringify(results[0].messages));
202202
});
203203

204204
test('typescript 4 space option', async t => {
@@ -270,7 +270,7 @@ async function configType(t, {dir}) {
270270
hasRule(
271271
results,
272272
path.resolve('fixtures', 'config-files', dir, 'file.js'),
273-
'no-var'
273+
'indent'
274274
)
275275
);
276276
}

Diff for: ‎test/lint-text.js

-12
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ test('extends support', t => {
102102
t.true(hasRule(results, 'react/jsx-no-undef'));
103103
});
104104

105-
test('extends support with `esnext` option', t => {
106-
const {results} = fn.lintText('import path from \'path\';\nlet React;\nReact.render(<App/>);\n', {
107-
extends: 'xo-react'
108-
});
109-
t.true(hasRule(results, 'react/jsx-no-undef'));
110-
});
111-
112105
test('disable style rules when `prettier` option is enabled', t => {
113106
const withoutPrettier = fn.lintText('(a) => {}\n', {filename: 'test.js'}).results;
114107
// `arrow-parens` is enabled
@@ -131,11 +124,6 @@ test('extends `react` support with `prettier` option', t => {
131124
t.true(hasRule(results, 'prettier/prettier'));
132125
});
133126

134-
test('always use the latest ECMAScript parser so esnext syntax won\'t throw in normal mode', t => {
135-
const {results} = fn.lintText('async function foo() {}\n\nfoo();\n');
136-
t.is(results[0].errorCount, 0);
137-
});
138-
139127
test('regression test for #71', t => {
140128
const {results} = fn.lintText('const foo = { key: \'value\' };\nconsole.log(foo);\n', {
141129
extends: path.join(__dirname, 'fixtures/extends.js')

Diff for: ‎test/options-manager.js

-26
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ test('buildConfig: defaults', t => {
4949
t.regex(slash(config.cacheLocation), /[\\/]\.cache\/xo-linter\/xo-cache.json[\\/]?$/u);
5050
t.is(config.useEslintrc, false);
5151
t.is(config.cache, true);
52-
t.is(config.baseConfig.extends[0], 'xo/esnext');
53-
});
54-
55-
test('buildConfig: esnext', t => {
56-
const config = manager.buildConfig({esnext: false});
5752
t.is(config.baseConfig.extends[0], 'xo');
5853
});
5954

@@ -171,27 +166,6 @@ test('buildConfig: prettier: true, space: 4', t => {
171166
t.is(config.rules['semi-spacing'], undefined);
172167
});
173168

174-
test('buildConfig: prettier: true, esnext: false', t => {
175-
const config = manager.buildConfig({prettier: true, esnext: false}, {});
176-
177-
// Sets `useTabs` and `tabWidth` options in `prettier/prettier` rule based on the XO `space` options
178-
t.deepEqual(config.rules['prettier/prettier'], ['error', {
179-
useTabs: true,
180-
bracketSpacing: false,
181-
jsxBracketSameLine: false,
182-
semi: true,
183-
singleQuote: true,
184-
tabWidth: 2,
185-
trailingComma: 'none'
186-
}]);
187-
// Indent rule is not enabled
188-
t.is(config.rules.indent, undefined);
189-
// Semi rule is not enabled
190-
t.is(config.rules.semi, undefined);
191-
// Semi-spacing is not enabled
192-
t.is(config.rules['semi-spacing'], undefined);
193-
});
194-
195169
test('buildConfig: prettier: true, space: true', t => {
196170
const config = manager.buildConfig({prettier: true, space: true}, {});
197171

0 commit comments

Comments
 (0)
Please sign in to comment.