-
Notifications
You must be signed in to change notification settings - Fork 48.7k
Refactor ESLint configuration to enable better IDE integration #13914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
'use strict'; | ||
|
||
const { | ||
es5Paths, | ||
esNextPaths, | ||
} = require('./scripts/shared/pathsByLanguageVersion'); | ||
|
||
const OFF = 0; | ||
const ERROR = 2; | ||
|
||
|
@@ -16,6 +21,15 @@ module.exports = { | |
'react-internal', | ||
], | ||
|
||
parser: 'espree', | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
sourceType: 'script', | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
}, | ||
}, | ||
|
||
// We're stricter than the default config, mostly. We'll override a few rules | ||
// and then enable some React specific ones. | ||
rules: { | ||
|
@@ -44,6 +58,13 @@ module.exports = { | |
'space-before-function-paren': OFF, | ||
'valid-typeof': [ERROR, {requireStringLiterals: true}], | ||
|
||
// We apply these settings to files that should run on Node. | ||
// They can't use JSX or ES6 modules, and must be in strict mode. | ||
// They can, however, use other ES6 features. | ||
// (Note these rules are overridden later for source files.) | ||
'no-var': ERROR, | ||
strict: ERROR, | ||
|
||
// React & JSX | ||
// Our transforms set this automatically | ||
'react/jsx-boolean-value': [ERROR, 'always'], | ||
|
@@ -71,6 +92,33 @@ module.exports = { | |
}, | ||
|
||
overrides: [ | ||
{ | ||
// We apply these settings to files that we ship through npm. | ||
// They must be ES5. | ||
files: es5Paths, | ||
parser: 'espree', | ||
parserOptions: { | ||
ecmaVersion: 5, | ||
sourceType: 'script', | ||
}, | ||
rules: { | ||
'no-var': OFF, | ||
strict: ERROR, | ||
}, | ||
}, | ||
{ | ||
// We apply these settings to the source files that get compiled. | ||
// They can use all features including JSX (but shouldn't use `var`). | ||
files: esNextPaths, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
sourceType: 'module', | ||
}, | ||
rules: { | ||
'no-var': ERROR, | ||
strict: OFF, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to turn this rule off because
|
||
}, | ||
}, | ||
{ | ||
files: ['**/__tests__/*.js'], | ||
rules: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
'use strict'; | ||
|
||
(function(global, factory) { | ||
// eslint-disable-next-line no-unused-expressions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding these to each UMD bundle, I could add another // .eslintrc.js
{
overrides: [
// ...
{
files: ['packages/*/npm/umd/*.js'],
rules: {
'no-unused-expressions': OFF,
}
}
]
} |
||
typeof exports === 'object' && typeof module !== 'undefined' | ||
? (module.exports = factory(require('react'))) | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.