-
Notifications
You must be signed in to change notification settings - Fork 214
Lint and build tasks display lint warnings differently #380
Comments
So, the point of the .neutrinorc.js is to try and unify the configuration for many tools. My first proposition would be to move the configuration for the linting into the .neutrinorc.js. Second, webpack is a module bundler, and the code it generates are technically modules, not scripts. the eslint middleware already sets the |
If it helps, this is documented here: |
But Also if you try to override this option explicitly it will have no effect: ['neutrino-middleware-eslint', {
eslint: {
useEslintrc: false,
parserOptions: {
sourceType: 'script'
}
}
}], |
See the ...since |
Ah I think I have an idea what's going on:
ie: The current behaviour of the That seems confusing and perhaps not what is intended. |
Yeah, that's not the intention. |
Ok. Overriding neutrino.config
.module.rule('lint')
.use('eslint')
.tap(function(options){
options.useEslintrc = true;
options.parserOptions = {};
return options;
}); @edmorley, I confirm the wrong behavior you mentioned
|
That's great :-) To summarise slightly, I think there were a few factors involved:
|
Reduced STR:
// .neutrinorc.js
module.exports = {
use: [
'neutrino-preset-web',
['neutrino-middleware-eslint', {
eslint: {
rules: {
'no-trailing-spaces': 'error',
'strict': 'warn',
}
}
}]
]
}; // ./src/index.js
'use strict';
// There is trailing whitespace at the end of this line -->
Expected:
Actual:
|
I haven't re-checked the source yet, but my guess is this is a discrepancy between how eslint-loader handles warnings and errors using CLIEngine in the |
I found an issue here trying to debug this. Calling this: const errors = CLIEngine.getErrorResults(report.results);
const formatted = formatter(report.results); The purpose of this was just to get the count of errors to determine whether to reject. Turns out it actually does an in-place mutation of I'll push some fixes shortly. |
Oh good spot! |
Test suite: https://mega.nz/#!mRlWkToS!7o74K5v1RKOAJ64JxQ8bAG77Ch6YUgP4ugmQ9Fj0a6o
That is a minimal config to reproduce the issue.
Run
npm run lint
. It will find a single ESLint rules violation. This is expected:Now run
npm run build
. Besides the previous error there is one additional warning.This is not expected as
'use strict'
is not a violation by rules.'use strict'
violations has "warning" severity, by the way, in.eslintrc
file. That's why it is not error but warning."sourceType": "script"
is also declared to allow strict directive, but build task thinks that it's"sourceType": "module"
for some reason.The text was updated successfully, but these errors were encountered: