Last active
August 30, 2023 21:36
-
-
Save srcrip/15bbbed19e7f522aa783e106c832619b to your computer and use it in GitHub Desktop.
Standard ESLint Setup for Svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
env: { | |
browser: true, | |
es2022: true | |
}, | |
extends: [ | |
'standard', | |
'eslint:recommended' | |
], | |
parser: '@typescript-eslint/parser', | |
parserOptions: { | |
sourceType: 'module', | |
ecmaVersion: 2022 | |
}, | |
plugins: [ | |
'svelte3', | |
'@typescript-eslint' | |
], | |
overrides: [ | |
{ | |
files: ['*.svelte'], | |
processor: 'svelte3/svelte3' | |
}, | |
{ | |
files: ['*.ts'], | |
extends: [ | |
'plugin:@typescript-eslint/recommended', | |
'plugin:@typescript-eslint/recommended-requiring-type-checking' | |
], | |
parserOptions: { | |
// Setting this inside the override is very important. | |
project: ['./tsconfig.json'] | |
} | |
}, | |
{ | |
files: ['*.js', '*.cjs', '*.mjs'], | |
extends: [ | |
'plugin:@typescript-eslint/recommended' | |
] | |
} | |
], | |
rules: { | |
// Needs fix from: https://github.com/sveltejs/eslint-plugin-svelte3/issues/41 | |
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 2, maxEOF: 0 }], | |
'no-self-assign': 'warn', | |
'@typescript-eslint/no-explicit-any': 'off' | |
}, | |
settings: { | |
'svelte3/typescript': () => require('typescript') | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// ... | |
"scripts": { | |
// ... | |
"check": "svelte-check --tsconfig ./tsconfig.json", | |
"lint": "eslint './src/**/*.{js,ts,svelte}'", | |
"lint:fix": "eslint --fix './src/**/*.{js,ts,svelte}'" | |
} | |
// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install NPM packages. | |
npm install -D eslint-plugin-svelte3 eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-standard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment