question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load plugin when using eslint in node via the API

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AntouanKcommented, Oct 12, 2015

@platinumazure Plugin works fine with CLIEngine and executeOnText. Thanks.

0reactions
nzakascommented, Oct 22, 2015

There is not. You must use CLIEngine

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found