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.

The config param of the linter.verify() method doesn't support "extends" property

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.5.0
  • Node Version: 6.5.0
  • npm Version: 3.10.6

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

{"extends": "eslint:recommended"}

What did you do? Please include the actual source code causing the issue.

const linter = require("eslint").linter;
const warnings = linter.verify("console.log();", {"extends": "eslint:recommended"});

What did you expect to happen? I expected linter.verify() to return an array with two warnings:

  • Unexpected console statement (no-console)
  • Newline required at end of file but not found (eol-last)

What actually happened? Please include the actual, raw output from ESLint. linter.verify() returned [] (an empty array)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
platinumazurecommented, Sep 10, 2016

Hi @EvgenyOrekhov, okay, then you want to use CLIEngine’s executeOnText() method to run the linter against your source text strings.

Here’s a rough idea of how you could do this:

const CLIEngine = require("eslint").CLIEngine;
const config = {"extends": "eslint:recommended"};
const sources = [
    "console.log('test');", // source code of a .js file
    "function myFunc() { ..." // source code of another .js file
];

cliEngine = new CLIEngine({
    baseConfig: config,
    useEslintrc: false   // Assuming that you don't want any .eslintrc in the filesystem to interfere. If you want .eslintrc, omit this
});

const warnings = sources.map((source) => cliEngine.executeOnText(source));

That should hopefully be very close to what you want. If you need to tweak the configuration options due to unexpected output or any other reason, take a good look at the many options that can be passed to the CLIEngine constructor.

Hope this helps-- if not, feel free to ask another question here or stop by on our Gitter chat.

0reactions
EvgenyOrekhovcommented, Sep 10, 2016

@platinumazure Thank you! Your suggestion solves my problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules - 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 >
How to fix eslintrc The file does not match your project config?
The error is basically saying the file eslintrc.js itself is both: Found by ESLint, but; Doesn't match the list of files it's supposed...
Read more >
Linter rules - Dart
Use the Dart linter to identify possible problems in your Dart code. You can use the linter through your IDE or with the...
Read more >
Testing services - Angular
The TestBed.configureTestingModule() method takes a metadata object that can have most of the properties of an @NgModule. To test a service, you set...
Read more >
Configuration | Stylelint
stylelintrc.js. The configuration object has the following properties: rules ​. Rules determine what the linter looks for and complains about.
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