Open insin opened 8 years ago
Would really like to see this, or at least a guide showing how I could add this via the nwb config.
Assuming you have eslint, eslint-loader and whatever plugins you need installed, plus an .eslintrc
, it should be something like this:
var extraWebpackConfig = {
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/
}
]
}
}
module.exports = {
webpack: {
extra: extraWebpackConfig
}
}
We would also need a way to disable use of NoEmitOnErrorsPlugin
, which nwb could do automatically if ESLint support is added and enabled.
Created https://github.com/MoOx/eslint-loader/issues/153, which would allow nwb to manage the ESLint dependency for you in a way which supports global usage.
@insin How would I now run just a linter step? I want to run the linter as part of the CI/CD pipeline so I would want something like the following in my package.json right?
"scripts": { "lint": "nwb lint" }
Or is there another way? This would need to terminate with a proper error code so the CI pipeline can respond correctly.
The PR MoOx/eslint-loader#183 been merged @insin.
Could we hope a default config with prettier and react
plugins?
{
"parser": "babel-eslint",
"plugins": [
"prettier",
"react"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"prettier"
]
}
@insin Is there any progress on this matter? I agree with you that some kind of linting would be nice to have, if not to check style, to only detect common pitfalls in the code.
I removed linting from an early version of nwb because code style is too divisive a subject, but create-react-app shows how useful including a default ESLint setup which only lints for correctness is.