This looks correct to me, but why does eslint show a rule violation, missing trailing comma comma-dangle
at the end of the last property "credentials"?
dispatch({
type: LOGIN_USER,
payload: credentials
});
.eslintrc
{
"extends": "airbnb",
"globals": {
"__DEV__": true
},
"rules": {
"react/jsx-quotes": 0,
"jsx-quotes": [2, "prefer-double"]
}
}
Require or disallow trailing commas. 🛠Some problems reported by this rule are automatically fixable by the --fix command line option.
Trailing commas in JSON As JSON is based on a very restricted subset of JavaScript syntax, trailing commas are not allowed in JSON. Both lines will throw a SyntaxError : JSON. parse("[1, 2, 3, 4, ]"); JSON. parse('{"foo" : 1, }'); // SyntaxError JSON.parse: unexpected character // at line 1 column 14 of the JSON data.
Description: In Python, a tuple is actually created by the comma symbol, not by the parentheses. Unfortunately, one can actually create a tuple by misplacing a trailing comma, which can lead to potential weird bugs in your code.
To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console.
I use the following combination (this works for me)
[1] .eslintrc.json
"rules": {
"comma-dangle": [2, "always-multiline"]
}
[2] JsPrettier | Prettier
"trailingComma": "all"
Results
dispatch({
type: LOGIN_USER,
payload: credentials,
});
Based on the airbnb
config the rule is setup like this
comma-dangle: [2, "always-multiline"]
.
Acoording to this, The expected
code is
dispatch({
type: LOGIN_USER,
payload: credentials,
});
It expects a ,
at the end.
More info on rule: http://eslint.org/docs/rules/comma-dangle
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