1.//solved including eslintrc.json inside project root with it's configuration.
// example:
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"extends": ["plugin:@typescript-eslint/recommended"],
"env": { "node": true },
"rules": {
"indent": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/explicit-function-return-type": "off"
}
}
2.// You need to configure eslint to support typescript
// as eslint doesn't support it out of the box.
// First, you need to install @typescript-eslint/parser and
// then @typescript-eslint/eslint-plugin. Once you have installed these,
// simply update your config as follows-
module.exports = {
'env': {
'browser': true,
'es2021': true,
node: true
},
'extends': [
'eslint:recommended',
'plugin:vue/vue3-essential'
],
'parserOptions': {
'ecmaVersion': 12,
'sourceType': 'module',
parser: '@typescript-eslint/parser'
},
'plugins': [
'vue',
'@typescript-eslint'
],
'rules': {
'vue/multi-word-component-names': 'off',
'vue/object-curly-spacing': [2, 'always'],
'vue/html-closing-bracket-spacing': [2, {
'selfClosingTag': 'always'
}],
'vue/max-attributes-per-line': [2, {
'singleline': {
'max': 1
},
'multiline': {
'max': 1
}
}],
'semi': [2, 'never']
}
}
3. //added this to my package.json:
"eslintConfig": {
"extends": [
"react-app"
]
},
// create-react-app --template typescript generates a package.json with this in it.
// error:
const o = {};
const a = o?.a; // Parsing error: Unexpected token .eslint
// solution for eslint config:
module.exports = {
env: { es2021: true },
parserOptions: { ecmaVersion: 12 },
rules: {...},
}