Skip to content

Commit e7afa61

Browse files
committed
Update eslint to current build structure for new vite projects
Move from .cjs to .js file for eslint Allow slightly longer lines Don't force blank lines between import groups (but allow them) Added lint:only and lint:fixonly when no localization needs compiling Eliminated unused lodash.throttle package. Moved the eslint-import-resolver-alias to the devDependences Add missing typescript-eslint to devDependencies Model the split tsconfig*.json for modern vite projects. Upgraded packages.
1 parent 3fcd5e7 commit e7afa61

File tree

8 files changed

+593
-368
lines changed

8 files changed

+593
-368
lines changed

ui/.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"singleQuote": false,
88
"plugins": ["prettier-plugin-tailwindcss"],
99
"tailwindFunctions": ["clsx", "cx"],
10-
"printWidth": 90,
10+
"printWidth": 100,
11+
"max_line_length": 100,
1112
"tailwindStylesheet": "./src/index.css"
1213
}
Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,67 @@
1-
const {
2-
defineConfig,
3-
globalIgnores,
4-
} = require("eslint/config");
1+
import globals from "globals";
2+
import { defineConfig, globalIgnores } from "eslint/config";
3+
import { fixupConfigRules } from "@eslint/compat";
4+
import js from "@eslint/js";
5+
import { FlatCompat } from "@eslint/eslintrc";
6+
import path from "path";
7+
import { fileURLToPath } from "url";
58

6-
const globals = require("globals");
9+
import tsParser from "@typescript-eslint/parser";
10+
import reactRefresh from "eslint-plugin-react-refresh";
711

8-
const {
9-
fixupConfigRules,
10-
} = require("@eslint/compat");
11-
12-
const js = require("@eslint/js");
13-
14-
const {
15-
FlatCompat,
16-
} = require("@eslint/eslintrc");
12+
// mimic CommonJS variables
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
1715

1816
const compat = new FlatCompat({
1917
baseDirectory: __dirname,
2018
recommendedConfig: js.configs.recommended,
2119
allConfig: js.configs.all
2220
});
2321

24-
const tsParser = require("@typescript-eslint/parser");
25-
const reactRefresh = require("eslint-plugin-react-refresh");
26-
27-
module.exports = defineConfig([{
22+
export default defineConfig([
23+
{
2824
languageOptions: {
29-
globals: {
30-
...globals.browser,
31-
},
32-
25+
globals: globals.browser,
3326
parser: tsParser,
3427
ecmaVersion: "latest",
3528
sourceType: "module",
36-
3729
parserOptions: {
38-
project: ["./tsconfig.json", "./tsconfig.node.json"],
30+
project: ["./tsconfig.app.json", "./tsconfig.node.json"],
3931
tsconfigRootDir: __dirname,
4032
ecmaFeatures: {
4133
jsx: true
4234
}
4335
},
4436
},
45-
4637
extends: fixupConfigRules(compat.extends(
4738
"eslint:recommended",
4839
"plugin:@typescript-eslint/recommended",
4940
"plugin:@typescript-eslint/stylistic",
50-
"plugin:react-hooks/recommended",
5141
"plugin:react/recommended",
42+
"plugin:react-hooks/recommended",
5243
"plugin:react/jsx-runtime",
5344
"plugin:import/recommended",
45+
"plugin:prettier/recommended",
5446
"prettier",
5547
)),
56-
5748
plugins: {
5849
"react-refresh": reactRefresh,
5950
},
60-
6151
rules: {
6252
"react-refresh/only-export-components": ["warn", {
6353
allowConstantExport: true,
6454
}],
6555

6656
"import/order": ["error", {
6757
groups: ["builtin", "external", "internal", "parent", "sibling"],
68-
"newlines-between": "always",
58+
"newlines-between": "ignore",
6959
}],
7060

7161
"@typescript-eslint/no-unused-vars": ["warn", {
7262
"argsIgnorePattern": "^_", "varsIgnorePattern": "^_"
7363
}],
7464
},
75-
7665
settings: {
7766
"react": {
7867
"version": "detect"
@@ -93,9 +82,9 @@ module.exports = defineConfig([{
9382
},
9483
},
9584
},
96-
}, globalIgnores([
85+
},
86+
globalIgnores([
9787
"**/dist",
98-
"**/.eslintrc.cjs",
9988
"**/tailwind.config.js",
10089
"**/postcss.config.js",
10190
])]);

0 commit comments

Comments
 (0)