admin管理员组

文章数量:1136516

I have following .eslintrc

{
    "extends": "standard"
}

I have following code in my javascript file

import React from 'react';

Above line of code is incorrect according to eslint. It gives following complain.

";                     Extra semicolon

How can I allow semi colons in eslint?

I have following .eslintrc

{
    "extends": "standard"
}

I have following code in my javascript file

import React from 'react';

Above line of code is incorrect according to eslint. It gives following complain.

";                     Extra semicolon

How can I allow semi colons in eslint?

Share Improve this question asked Nov 6, 2016 at 20:01 Om3gaOm3ga 32.8k45 gold badges149 silver badges229 bronze badges 1
  • Standard JS is well-known for omitting semicolons. Why do you want to add them if you're using Standard? – Ryan Commented Feb 1, 2018 at 1:57
Add a comment  | 

2 Answers 2

Reset to default 186

eslint-config-standard uses the following rule for semicolons:

"semi": [2, "never"]

The documentation for the rule lists its options:

  • "always" (default) requires semicolons at the end of statements
  • "never" disallows semicolons as the end of statements (except to disambiguate statements beginning with [, (, /, +, or -

To overide the rule, you could modify your .eslintrc to always require semicolons:

{
    "extends": "standard",
    "rules": {
        "semi": [2, "always"]
    }
}

Or to disable the rule:

{
    "extends": "standard",
    "rules": {
        "semi": 0
    }
}

Modify your .eslintrc (deprecated) or .eslintrc.js(recommended) with

{
    "extends": "standard",
    "rules": {
        "semi": [1, "always"]
    }
}

Good Luck...

本文标签: buildallow semi colons in javascript eslintStack Overflow