Matarishvan
Matarishvan

Reputation: 2422

How to use ESLint

Basically i have installed ESLint from here

http://eslint.org/docs/user-guide/getting-started

.eslintrs.json looks like this

    {
    "extends": ["eslint:recommended",
                "angular",
                "plugin:jasmine/recommended"],
    "installedESLint": true,
    "plugins": [
        "standard",
        "promise",
        "jasmine"
    ],
    "rules": {
        "strict": 0,
        "indent": [2, 4],
        "quotes": [2, "single"],
        "no-unused-vars": 1,
        "no-underscore-dangle": 1
    },
    "env": {
        "jasmine": true
    },
    "globals": {
        "navigator": true
    }
}

Basically there are few .js files i need to check with the extra spaces and unnecessary lines. So did

eslint myfile.js

This is what i am getting Automatic Configuration failed. No files were able to be parsed.

How to use ESLint to remove unnecessary spaces and lines for a js files?

Upvotes: 0

Views: 4836

Answers (2)

Marina ES
Marina ES

Reputation: 270

That means you did not configured the path where ESLINT will check your code.

GO to your_project\node_modules.bin folder, run eslint --init then you will need to answer to these questions :

  • ? How would you like to configure ESLint?
  • ? Which file(s), path(s), or glob(s) should be examined?
  • ? What format do you want your config file to be in?
  • ? Are you using ECMAScript 6 features?
  • ? Are you using ES6 modules?
  • ? Where will your code run? Browser, Node
  • ? Do you use CommonJS?
  • ? Do you use JSX?

Be careful about the second question to do not have a "No files were able to be parsed" error

Upvotes: 0

Chris Lam
Chris Lam

Reputation: 3614

The configuration file should be .eslintrc.*, or simply .eslintrc

http://eslint.org/docs/user-guide/configuring

Configuration Files - use a JavaScript, JSON or YAML file to specify configuration information for an entire directory and all of its subdirectories. This can be in the form of an .eslintrc.* file or an eslintConfig field in a package.json file, both of which ESLint will look for and read automatically, or you can specify a configuration file on the command line.

Edit:

You can append --fix to ask ESLint to auto-fix problems found.

eg.

eslint myfile.js mydir --fix

Upvotes: 1

Related Questions