Skip to content

Commit

Permalink
[BREAKING] upgrade ESLint and get rid of babel-eslint
Browse files Browse the repository at this point in the history
ESLint now supports ES2017 \o/

This will be a breaking change if you used things like decorators or Flow syntax.
  • Loading branch information
sindresorhus committed Sep 25, 2016
1 parent 980873b commit 04733f1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 31 deletions.
20 changes: 1 addition & 19 deletions config/overrides.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
'use strict';
module.exports = {
// always use the Babel parser so it won't throw
// on esnext features in normal mode
parser: 'babel-eslint',
plugins: ['babel'],
rules: {
'generator-star-spacing': 0,
'new-cap': 0,
'array-bracket-spacing': 0,
'object-curly-spacing': 0,
'arrow-parens': 0,
'babel/generator-star-spacing': [2, 'both'],
'babel/new-cap': [2, {
newIsCap: true,
capIsNew: true
}],
'babel/array-bracket-spacing': [2, 'never'],

This comment has been minimized.

Copy link
@jfmengels

jfmengels Sep 25, 2016

Contributor

Are you sure this one can be removed?

This comment has been minimized.

Copy link
@sindresorhus
'babel/object-curly-spacing': [2, 'never'],
'babel/arrow-parens': [2, 'as-needed']
}
// put rule overrides here
};
9 changes: 9 additions & 0 deletions config/plugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
'use strict';
module.exports = {
// repeated here from eslint-config-xo in case some plugins set something different
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true
}
},
plugins: [
'no-use-extend-native',
'ava',
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@
],
"dependencies": {
"arrify": "^1.0.0",
"babel-eslint": "^6.0.0",
"debug": "^2.2.0",
"deep-assign": "^1.0.0",
"eslint": "^3.5.0",
"eslint-config-xo": "^0.15.0",
"eslint": "^3.6.0",
"eslint-config-xo": "^0.16.0",
"eslint-formatter-pretty": "^1.0.0",
"eslint-plugin-ava": "^3.0.0",
"eslint-plugin-babel": "^3.1.0",
"eslint-plugin-import": "^1.7.0",
"eslint-plugin-no-use-extend-native": "^0.3.2",
"eslint-plugin-promise": "^2.0.1",
Expand Down Expand Up @@ -97,6 +95,6 @@
"nyc": "^8.3.0",
"proxyquire": "^1.7.3",
"temp-write": "^2.0.1",
"xo": "file:."
"xo": "sindresorhus/xo#v0.16.0"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Default: `false`

Enforce ES2015+ rules. Enabling this will *prefer* ES2015+ syntax and conventions.

*ES2015+ is parsed even without this option. You can already use ES2016 features like [`async`/`await`](https://github.com/lukehoban/ecmascript-asyncawait) and [decorators](https://github.com/wycats/javascript-decorators). For a full list of features see [Babel's experimental features](https://babeljs.io/docs/plugins/#stage-x-experimental-presets) and their [Learn ES2015](https://babeljs.io/docs/learn-es2015/).*
*ES2015+ is parsed even without this option. You can already use ES2017 features like [`async`/`await`](https://github.com/lukehoban/ecmascript-asyncawait).

### envs

Expand Down
6 changes: 3 additions & 3 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ test('.lintText()', t => {
});

test('.lintText() - `esnext` option', t => {
const results = fn.lintText('function dec() {}\nconst x = {\n\t@dec()\n\ta: 1\n};\n', {esnext: true}).results;
t.true(hasRule(results, 'no-unused-vars'));
const results = fn.lintText('var foo = true;', {esnext: true}).results;
t.true(hasRule(results, 'no-var'));
});

test('.lintText() - JSX support', t => {
Expand Down Expand Up @@ -47,7 +47,7 @@ test('.lintText() - extends support with `esnext` option', t => {
t.true(hasRule(results, 'react/jsx-no-undef'));
});

test('always use the Babel parser so esnext syntax won\'t throw in normal mode', t => {
test('always use the latest ECMAScript parser so esnext syntax won\'t throw in normal mode', t => {
const results = fn.lintText('async function foo() {}\n\nfoo();\n').results;
t.is(results[0].errorCount, 0);
});
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/extends.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
module.exports = {
rules: {
'babel/object-curly-spacing': 0
'object-curly-spacing': 0
}
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test('buildConfig: semicolon', t => {
});

test('buildConfig: rules', t => {
const rules = {'babel/object-curly-spacing': [2, 'always']};
const rules = {'object-curly-spacing': [2, 'always']};
const config = manager.buildConfig({rules: rules});
t.deepEqual(config.rules, rules);
});
Expand Down

4 comments on commit 04733f1

@wmertens
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand this correctly, if you're using stage-2 or stage-1 things, this will break linting? Isn't this very breaking? Is there an option to keep using babel-eslint?

@jfmengels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking, yes. I'm pretty sure you can install babel-eslint yourself and specify the parser to use.

@wmertens
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the point of XO making the use ESLint easier by providing things like "space" and "semicolon"? I would expect a setting like "babel"… I'm not even sure XO lets you override the parser…

@sindresorhus
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wmertens I only used babel-eslint to get async functions. Now that it's part of ESLint, I see no point in having the overhead. babel-eslint was a nightmare to maintain. It was constantly buggy, slower, blocked upgrading to latest ESLint many times, not very actively maintained. Should be easy to add a parser option. Open an issue/PR if you need it.

Please sign in to comment.