Skip to content

Instantly share code, notes, and snippets.

@srcrip
Last active August 30, 2023 21:36
Show Gist options
  • Save srcrip/15bbbed19e7f522aa783e106c832619b to your computer and use it in GitHub Desktop.
Save srcrip/15bbbed19e7f522aa783e106c832619b to your computer and use it in GitHub Desktop.
Standard ESLint Setup for Svelte
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')
}
}
{
// ...
"scripts": {
// ...
"check": "svelte-check --tsconfig ./tsconfig.json",
"lint": "eslint './src/**/*.{js,ts,svelte}'",
"lint:fix": "eslint --fix './src/**/*.{js,ts,svelte}'"
}
// ...
}
# 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