Load plugin when using eslint in node via the API
See original GitHub issueI’m having an issue with using the react
plugin, and from what I see the problem is the way I use eslint.
( Made an issue there as I thought it was a plugin issue )
So if I run this
node ./node_modules/eslint/bin/eslint.js -c ./.eslintrc ./src
on my root directory, works fine, no errors/warnings. ( version : v1.6.0 )
I use eslint in my gulp step though, and I want to be able to use the plugin there. That’s how I use eslint now:
const eslint = require('eslint');
// get a linter reference
const linter = eslint.linter;
// read .eslintrc
const eslintrc = JSON.parse(
fs.readFileSync( path.resolve(__dirname, '.eslintrc') ).toString()
);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lint-scripts
gulp.task('lint-scripts', () => {
return gulp.src([
`${paths.scripts}/**/*.js`,
`${paths.scripts}/**/*.jsx`
])
.pipe(
tap(file => {
let fileContents = file.contents.toString();
let messages = linter.verify(fileContents, eslintrc);
if(messages.length > 0){
messages
.map(msg => {
msg.filePath = file.path;
return msg;
})
.forEach(lintLogger);
}
})
);
});
lintLogger
is a custom log function for me to see warnings/errors.
So when I use that version, the plugin is not loaded.
In the API section, there is an addPlugin
method, but apparently it’s for the CLI engine, not for the linter.
Any way to load the plugins on the node exposed linter? ( I thought the configuration I load should be enough )
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Node.js API - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >Failed to load plugin '@typescript-eslint' declared in 'package ...
I am reading the issue here: https://github.com/facebook/create-react-app/issues/11856. You can try to update your node.js version.
Read more >eslint/eslint - Gitter
The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc). 2. If ESLint is installed globally, then make sure ...
Read more >Migrate from TSLint to ESLint - Visual Studio Code
ESLint : Run · Install the ESLint extension. · Create a task via the Tasks: Configure Task command and select npm: lint. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@platinumazure Plugin works fine with
CLIEngine
andexecuteOnText
. Thanks.There is not. You must use
CLIEngine