-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(eslint): ensure all config values are contained in config file
- Loading branch information
Showing
6 changed files
with
80 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
module.exports = api => { | ||
const options = { | ||
extensions: ['.js', '.vue'], | ||
envs: ['node'], | ||
exports.config = api => { | ||
const config = { | ||
root: true, | ||
env: { node: true }, | ||
extends: ['plugin:vue/essential'], | ||
rules: { | ||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' | ||
'no-console': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'error' : 'off'`), | ||
'no-debugger': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'error' : 'off'`) | ||
} | ||
} | ||
|
||
if (api.hasPlugin('typescript')) { | ||
options.extensions.push('.ts') | ||
} else { | ||
options.parserOptions = { | ||
parser: require.resolve('babel-eslint') | ||
if (!api.hasPlugin('typescript')) { | ||
config.parserOptions = { | ||
parser: 'babel-eslint' | ||
} | ||
} | ||
return config | ||
} | ||
|
||
return options | ||
// __expression is a special flag that allows us to customize stringification | ||
// output when extracting configs into standalone files | ||
function makeJSOnlyValue (str) { | ||
const fn = () => {} | ||
fn.__expression = str | ||
return fn | ||
} | ||
|
||
const baseExtensions = ['.js', '.jsx', '.vue'] | ||
exports.extensions = api => api.hasPlugin('typescript') | ||
? baseExtensions.concat('.ts', '.tsx') | ||
: baseExtensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters