-
Notifications
You must be signed in to change notification settings - Fork 22
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
[WIP] - Update Eslint Configuartion Strategy #50
Open
id-pogni
wants to merge
2
commits into
master
Choose a base branch
from
feature/update-eslint-configuartion-strategy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const CONFIG_WEBPACK = require('./internals/webpack.config.js'); | ||
|
||
module.exports = { | ||
// Optional: Replace `eslint:recommended` with `eslint-config-infield` and run | ||
// `npm install --save-dev eslint-config-infield` for stricter linting rules | ||
extends: "eslint:recommended", | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 8, | ||
sourceType: 'module', | ||
}, | ||
settings: { | ||
// This prevents `no-unused-vars` and `import/no-unresolved` from being thrown | ||
// when modules are imported that are defined in Webpack but not correctly | ||
// resolved by `eslint-plugin-import`. Note that `eslint-plugin-import` can | ||
// be defined directly in this project's package.json but it can also be an | ||
// dependency of an extended ESLint configuration. | ||
'import/resolver': { | ||
node: { | ||
paths: (CONFIG_WEBPACK.resolve && CONFIG_WEBPACK.resolve.modules) || [], | ||
}, | ||
}, | ||
}, | ||
|
||
// If you want to define variables that are available across various processed JavaScript | ||
// files, define them here. More details: http://eslint.org/docs/user-guide/configuring#specifying-globals | ||
globals: { | ||
$: true, | ||
Granite: true, | ||
}, | ||
|
||
rules: { | ||
"no-console" : 1, // 0 = off, 1 = warn, 2 = error | ||
} | ||
} |
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,29 +1,9 @@ | ||
const merge = require('merge'); | ||
const CONFIG = require('./../../webpack.project'); | ||
const CONFIG_WEBPACK = require('./webpack.config.js'); | ||
const CONFIG = require('../../webpack.project'); | ||
const path = require('path'); | ||
|
||
const ESLINT_DEFAULT = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 8, | ||
sourceType: 'module', | ||
}, | ||
settings: { | ||
// This prevents `no-unused-vars` and `import/no-unresolved` from being thrown | ||
// when modules are imported that are defined in Webpack but not correctly | ||
// resolved by `eslint-plugin-import`. Note that `eslint-plugin-import` can | ||
// be defined directly in this project's package.json but it can also be an | ||
// dependency of an extended ESLint configuration. | ||
'import/resolver': { | ||
node: { | ||
paths: (CONFIG_WEBPACK.resolve && CONFIG_WEBPACK.resolve.modules) || [], | ||
}, | ||
}, | ||
}, | ||
extends: path.resolve(__dirname, '../.eslintrc.js'), | ||
}; | ||
|
||
module.exports = merge.recursive(true, ESLINT_DEFAULT, CONFIG.eslint); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I purposefully placed those few lines into
webpack.project
so users of this Webpack setup have it easy to adjust the ESLint config in the right place. If this part gets moved intowebpack.core
, I suspect that people will modify the file in thewebpack.core
folder directly instead of making the effort of overriding the code viawebpack.project
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree with you and I think you are correct. After I submitted this PR, I was looking into elegant ways to have a base config in webpack.core which is extended in webpack.project.
I also think it's rare for a company to need different ESLint rules for different projects. If that is needed, then a developer could create a new project-name/.eslintrc.js/json file which extends the default.
Thank you for reviewing this Kevin! Your feedback is really appreciated. This PR isn't done, and I should have marked it as a work in progress [WIP].