I generated SvelteKit project using npm create svelte@latest
and added some .ts
files for some library but running eslint.
it cant find errors.
I have this default eslint config generate from svelte.
.eslintrc.cjs
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
settings: {
'svelte3/typescript': () => require('typescript')
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
env: {
browser: true,
es2017: true,
node: true
}
};
and tsconfig.json
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
}
I have this lint on package.json
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
Running npm run lint
it cant find any errors even there is clearly an error to a .ts
file.
It only can detect errors from .svelte
files.
Is there something wrong with my eslint or tsconfig or I miss something?
My bad, it is linting the .ts
files but some rules is missing from what i used to be and not showing errors so I add some rules instead of using the default one and now it showing errors.
Here is my new config
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier'
],
plugins: ['node', 'prettier', 'svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs', 'svelte.config.js', 'vite.config.js'],
overrides: [
{ files: ['*.svelte'], processor: 'svelte3/svelte3' },
{
files: ['*.ts', '*.js', '*.svelte'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'node/no-missing-import': 'off',
'node/no-unpublished-import': 'off'
}
}
],
settings: {
'svelte3/typescript': () => require('typescript')
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
project: ['./tsconfig.json']
},
env: {
browser: true,
es2017: true,
node: true
},
rules: {
'prettier/prettier': 'error',
'block-scoped-var': 'error',
eqeqeq: 'error',
'no-var': 'error',
'prefer-const': 'error',
'eol-last': 'error',
'prefer-arrow-callback': 'error',
'no-trailing-spaces': 'error',
quotes: ['warn', 'single', { avoidEscape: true }],
'no-restricted-properties': [
'error',
{
object: 'describe',
property: 'only'
},
{
object: 'it',
property: 'only'
}
]
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.