I used the ?. syntax in my code, but when I configure eslint into my project, they marked such constructions as a parsing error (Unexpected token)
const currentFiles = folder?.files
Here is my eslint configuration
{
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"],
"react/react-in-jsx-scope": "off",
"import/no-unresolved": "off",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"jsx-a11y/label-has-associated-control": ["error", {
"required": {
"some": ["nesting", "id"]
}
}],
"jsx-a11y/label-has-for": ["error", {
"required": {
"some": ["nesting", "id"]
}
}]
}
}
Is there a way to configure linter somehow so it won't be any error anymore?
I used the ?. syntax in my code, but when I configure eslint into my project, they marked such constructions as a parsing error (Unexpected token)
const currentFiles = folder?.files
Here is my eslint configuration
{
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"],
"react/react-in-jsx-scope": "off",
"import/no-unresolved": "off",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"jsx-a11y/label-has-associated-control": ["error", {
"required": {
"some": ["nesting", "id"]
}
}],
"jsx-a11y/label-has-for": ["error", {
"required": {
"some": ["nesting", "id"]
}
}]
}
}
Is there a way to configure linter somehow so it won't be any error anymore?
Share Improve this question edited Jun 19, 2021 at 19:07 glinda93 8,4996 gold badges50 silver badges87 bronze badges asked Jun 19, 2021 at 19:02 Екатерина ЯцкивЕкатерина Яцкив 651 silver badge6 bronze badges 1- What react version? and how you created the project? CRA ? eslint version ? and code example ? – sathishk2030 Commented Jun 19, 2021 at 19:11
1 Answer
Reset to default 8Support of ?.
operator (optional chaining) has been added to ESLint in version 7.5.0:
The default parser and built-in rules will support this syntax when you enable
parserOptions.ecmaVersion: 2020
in your configuration:
{
"parserOptions": {
"ecmaVersion": 2020
}
}