mirror of
https://github.com/garraflavatra/yeslint.git
synced 2024-11-21 23:49:05 +01:00
Add parserOptions for Svelte + TypeScript
This commit is contained in:
parent
27d8247ad0
commit
5d5d224d25
@ -2,6 +2,14 @@
|
||||
|
||||
const generic = require('./generic.js');
|
||||
|
||||
let typescriptInstalled = true;
|
||||
|
||||
try {
|
||||
require('typescript');
|
||||
typescriptInstalled = true;
|
||||
}
|
||||
catch { /* not installed */ }
|
||||
|
||||
/**
|
||||
* An extension on the default yeslint! generic config, with rules specific to
|
||||
* Svelte codebases and JavaScript source code for browser environments.
|
||||
@ -12,6 +20,7 @@ const generic = require('./generic.js');
|
||||
* @type {import('eslint').Linter.Config}
|
||||
*/
|
||||
const svelte = {
|
||||
...generic,
|
||||
parserOptions: {
|
||||
...generic.parserOptions,
|
||||
ecmaVersion: 2020,
|
||||
@ -31,18 +40,16 @@ const svelte = {
|
||||
...generic.plugins,
|
||||
'svelte',
|
||||
],
|
||||
overrides: [ {
|
||||
overrides: [
|
||||
...generic.overrides,
|
||||
{
|
||||
files: '*.svelte',
|
||||
parser: 'svelte-eslint-parser',
|
||||
parserOptions: typescriptInstalled ? {
|
||||
parser: '@typescript-eslint/parser',
|
||||
} : undefined,
|
||||
rules: {
|
||||
'no-inner-declarations': 0,
|
||||
'max-len': [
|
||||
'warn',
|
||||
{
|
||||
...generic.rules['max-len'][1],
|
||||
code: 200,
|
||||
},
|
||||
],
|
||||
'svelte/no-inner-declarations': [
|
||||
'error',
|
||||
'functions',
|
||||
@ -97,7 +104,8 @@ const svelte = {
|
||||
'all',
|
||||
],
|
||||
},
|
||||
} ],
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
...generic.rules,
|
||||
strict: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user