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?
This rule has two options, a string option and an object option. String option: "always" (default) requires semicolons at the end of statements. "never" disallows semicolons as the end of statements (except to disambiguate statements beginning with [ , ( , / , + , or - )
Semicolons are an essential part of JavaScript code. They are read and used by the compiler to distinguish between separate statements so that statements do not leak into other parts of the code. The good news is that JavaScript includes an automatic semicolon feature.
The JavaScript parser will automatically add a semicolon when, during the parsing of the source code, it finds these particular situations: when the next line starts with code that breaks the current one (code can spawn on multiple lines) when the next line starts with a } , closing the current block.
There are two primary ways to configure ESLint: Configuration Comments - use JavaScript comments to embed configuration information directly into a file. Configuration Files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories.
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 } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With