Skip to content

Commit f07805a

Browse files
committed
Add prettier and eslint from WebUI repository
1 parent 7c808fe commit f07805a

5 files changed

Lines changed: 4397 additions & 665 deletions

File tree

backend/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
README.md
2+
config.json
3+
config.sample.json
4+
data
5+
dist

backend/.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 90,
3+
"tabWidth": 2,
4+
"singleQuote": true,
5+
"trailingComma": "none",
6+
"endOfLine": "auto"
7+
}

backend/eslint.config.mjs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import globals from 'globals';
2+
import eslintConfigPrettier from 'eslint-config-prettier';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
6+
import react from 'eslint-plugin-react';
7+
import tseslint from 'typescript-eslint';
8+
import js from '@eslint/js';
9+
10+
export default tseslint.config(
11+
{ ignores: ['dist'] },
12+
{
13+
extends: [
14+
js.configs.recommended,
15+
...tseslint.configs.recommended,
16+
eslintConfigPrettier
17+
],
18+
files: ['**/*.{ts,tsx}'],
19+
ignores: ['**/*.d.ts'],
20+
languageOptions: {
21+
ecmaVersion: 2020,
22+
globals: globals.browser
23+
},
24+
plugins: {
25+
'react-hooks': reactHooks,
26+
'react-refresh': reactRefresh,
27+
react: react,
28+
'simple-import-sort': simpleImportSort
29+
},
30+
linterOptions: {
31+
reportUnusedDisableDirectives: 'error'
32+
},
33+
rules: {
34+
...reactHooks.configs.recommended.rules,
35+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
36+
'@typescript-eslint/no-explicit-any': 'error', // Disallow usage of any
37+
'no-duplicate-imports': 'error', // Imports should be on one line
38+
'no-console': 'warn',
39+
'prefer-destructuring': ['error', { object: true, array: true }],
40+
'simple-import-sort/imports': 'error',
41+
'simple-import-sort/exports': 'error',
42+
'simple-import-sort/imports': [
43+
'error',
44+
{
45+
groups: [
46+
// Packages `react` related packages come first.
47+
['^react', '^@?\\w'],
48+
// Internal packages.
49+
['^(@|components)(/.*|$)'],
50+
// Side effect imports.
51+
['^\\u0000'],
52+
// Parent imports. Put `..` last.
53+
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
54+
// Other relative imports. Put same-folder imports and `.` last.
55+
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
56+
// Style imports.
57+
['^.+\\.?(css)$']
58+
]
59+
}
60+
],
61+
'react/jsx-curly-brace-presence': [
62+
'error',
63+
{
64+
props: 'always',
65+
children: 'never',
66+
propElementValues: 'always'
67+
}
68+
],
69+
// Guards against stupidity
70+
'no-self-compare': 'error',
71+
'no-unreachable-loop': 'error',
72+
'no-template-curly-in-string': 'error', // Catches "${}" template strings
73+
'default-case': ['error', { commentPattern: '^skip\\sdefault' }], // require default switch case
74+
'default-case-last': 'error' // enforce default switch case last
75+
}
76+
}
77+
);

0 commit comments

Comments
 (0)