Skip to content

Commit

Permalink
feat(ui-imports): add eslint imports config and sort script
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Nov 4, 2024
1 parent d0337e6 commit 1bb2a2d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
39 changes: 30 additions & 9 deletions webapp/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@ module.exports = {
"plugin:jsdoc/recommended-typescript",
"plugin:prettier/recommended", // Must be the last one
],
plugins: [
"license-header",
"react-refresh",
],
ignorePatterns: [
"dist",
"license-header.js",
".eslintrc.cjs",
],
plugins: ["license-header", "react-refresh", "simple-import-sort"],
ignorePatterns: ["dist", "license-header.js", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
parserOptions: {
// `ecmaVersion` is automatically sets by `esXXXX` in `env`
Expand Down Expand Up @@ -85,5 +78,33 @@ module.exports = {
"react/prop-types": "off",
"react/self-closing-comp": "error",
"require-await": "warn", // TODO: switch to "error" when the quantity of warning will be low
"simple-import-sort/imports": [
"error",
{
groups: [
// React first, then packages starting with a character
["^react$", "^[a-z]"],

// Packages starting with `@` (except our internal @/)
["^@(?!/)"],

// Internal imports from src using @/
["^@/"],

// Imports starting with `../`
["^\\.\\.(?!/?$)", "^\\.\\./?$"],

// Imports starting with `./`
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],

// Style imports
["^.+\\.s?css$"],

// Side effect imports
["^\\u0000"],
],
},
],
"simple-import-sort/exports": "error",
},
};
1 change: 1 addition & 0 deletions webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.temp-eslint.json
10 changes: 10 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"eslint-plugin-react": "7.37.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-refresh": "0.4.12",
"eslint-plugin-simple-import-sort": "12.1.1",
"husky": "9.1.6",
"jsdom": "25.0.1",
"prettier": "3.3.3",
Expand Down

0 comments on commit 1bb2a2d

Please sign in to comment.