allow semi colons in javascript eslint

JavascriptBuildEslint

Javascript Problem Overview


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?

Javascript Solutions


Solution 1 - Javascript

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

Solution 2 - Javascript

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

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

Good Luck...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOm3gaView Question on Stackoverflow
Solution 1 - JavascriptcartantView Answer on Stackoverflow
Solution 2 - JavascriptNishaView Answer on Stackoverflow