Skip to content

Commit 39bdcf0

Browse files
committed
[svelte] Lint
1 parent 930e4c5 commit 39bdcf0

31 files changed

Lines changed: 8707 additions & 1628 deletions

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"singleQuote": true,
44
"trailingComma": "all",
55
"plugins": [
6-
"prettier-plugin-organize-imports"
6+
"prettier-plugin-organize-imports",
7+
"prettier-plugin-svelte"
78
]
89
}

eslint.config.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import importLint from 'eslint-plugin-import';
33
import jsdocLint from 'eslint-plugin-jsdoc';
44
import reactLint from 'eslint-plugin-react';
55
import hooksLint from 'eslint-plugin-react-hooks';
6+
import svelteLint from 'eslint-plugin-svelte';
67
import {globalIgnores} from 'eslint/config';
78
import globals from 'globals';
9+
import * as svelteParser from 'svelte-eslint-parser';
810
import tsLint from 'typescript-eslint';
911

1012
export default tsLint.config(
@@ -17,6 +19,8 @@ export default tsLint.config(
1719
'**/node_modules/**/*',
1820
]),
1921

22+
...svelteLint.configs['flat/recommended'],
23+
2024
jsLint.configs.recommended,
2125
importLint.flatConfigs.recommended,
2226
jsdocLint.configs['flat/recommended'],
@@ -29,7 +33,7 @@ export default tsLint.config(
2933
settings: {
3034
react: {version: 'detect'},
3135
'import/resolver': {node: {extensions: ['.js', '.jsx', '.ts', '.tsx']}},
32-
'import/core-modules': ['expo-sqlite'],
36+
'import/core-modules': ['expo-sqlite', 'svelte'],
3337
},
3438

3539
languageOptions: {globals: {...globals.node, ...globals.browser}},
@@ -52,7 +56,7 @@ export default tsLint.config(
5256
{
5357
code: 80,
5458
ignorePattern:
55-
'^(\\s+\\* )?(imports?|exports?|\\} from|(.+ as .+))\\W.*',
59+
'^\\s*(\\* )?(imports?|exports?|\\} from|(.+ as .+))\\W.*',
5660
ignoreUrls: true,
5761
},
5862
],
@@ -190,4 +194,34 @@ export default tsLint.config(
190194
files: ['eslint.config.js'],
191195
extends: [tsLint.configs.disableTypeChecked],
192196
},
197+
198+
{
199+
files: ['**/*.svelte'],
200+
languageOptions: {
201+
parser: svelteParser,
202+
parserOptions: {parser: tsLint.parser},
203+
},
204+
rules: {
205+
'react/prop-types': 0,
206+
'react/react-in-jsx-scope': 0,
207+
'react/no-multi-comp': 0,
208+
'react-hooks/exhaustive-deps': 0,
209+
'react-hooks/rules-of-hooks': 0,
210+
'jsdoc/require-jsdoc': 0,
211+
'svelte/no-useless-mustaches': 0,
212+
'svelte/prefer-writable-derived': 0,
213+
'import/namespace': 0,
214+
'import/named': 0,
215+
'import/default': 0,
216+
'import/no-named-as-default': 0,
217+
'import/no-named-as-default-member': 0,
218+
},
219+
},
220+
221+
{
222+
files: ['**/*.svelte.ts'],
223+
rules: {
224+
'svelte/prefer-writable-derived': 0,
225+
},
226+
},
193227
);

gulpfile.mjs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,19 @@ const lintCheckFiles = async (dir) => {
332332
const prettierConfig = await getPrettierConfig();
333333

334334
const filePaths = [];
335-
['.ts', '.tsx', '.js', '.d.ts'].forEach((extension) =>
335+
['.ts', '.tsx', '.js', '.d.ts', '.svelte'].forEach((extension) =>
336336
forEachDeepFile(dir, (filePath) => filePaths.push(filePath), extension),
337337
);
338338
await allOf(filePaths, async (filePath) => {
339+
const fileConfig = filePath.endsWith('.svelte')
340+
? {...prettierConfig, filepath: filePath, parser: undefined}
341+
: {...prettierConfig, filepath: filePath};
339342
const code = await promises.readFile(filePath, UTF8);
340-
if (
341-
!(await prettier.check(code, {...prettierConfig, filepath: filePath}))
342-
) {
343+
if (!(await prettier.check(code, fileConfig))) {
343344
writeFileSync(
344345
filePath,
345-
await prettier.format(
346-
code,
347-
{...prettierConfig, filepath: filePath},
348-
UTF8,
349-
),
346+
await prettier.format(code, fileConfig),
347+
UTF8,
350348
);
351349
}
352350
});

0 commit comments

Comments
 (0)