Skip to content

Commit 4a74817

Browse files
committed
[refactor] upgrade to ESLint 9
[add] Prettier CSS softer [add] GitHub PR badges & GitPod extensions
1 parent c5a6229 commit 4a74817

File tree

16 files changed

+597
-285
lines changed

16 files changed

+597
-285
lines changed

.eslintrc.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/pr-badge.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- icon: visualstudio
2+
label: 'GitHub.dev'
3+
message: 'PR-$prNumber'
4+
color: 'blue'
5+
url: 'https://github.dev/$owner/$repo/pull/$prNumber'
6+
7+
- icon: github
8+
label: 'GitHub codespaces'
9+
message: 'PR-$prNumber'
10+
color: 'black'
11+
url: 'https://codespaces.new/$owner/$repo/pull/$prNumber'
12+
13+
- icon: git
14+
label: 'GitPod.io'
15+
message: 'PR-$prNumber'
16+
color: 'orange'
17+
url: 'https://gitpod.io/?autostart=true#https://github.com/$owner/$repo/pull/$prNumber'

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
jobs:
77
Build-and-Publish:
88
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
id-token: write
912
steps:
1013
- uses: actions/checkout@v4
1114

.gitpod.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This configuration file was automatically generated by Gitpod.
2+
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
3+
# and commit this file to your remote git repository to share the goodness with others.
4+
5+
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
6+
7+
vscode:
8+
extensions:
9+
- yzhang.markdown-all-in-one
10+
- jock.svg
11+
- redhat.vscode-yaml
12+
- clinyong.vscode-css-modules
13+
- akamud.vscode-caniuse
14+
- visualstudioexptteam.intellicode-api-usage-examples
15+
- pflannery.vscode-versionlens
16+
- christian-kohler.npm-intellisense
17+
- esbenp.prettier-vscode
18+
- rangav.vscode-thunder-client
19+
- eamodio.gitlens
20+
- github.vscode-pull-request-github
21+
- github.vscode-github-actions
22+
tasks:
23+
- init: pnpm i
24+
command: pnpm build

eslint.config.mjs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// @ts-check
2+
import { fixupPluginRules } from '@eslint/compat';
3+
import eslint from '@eslint/js';
4+
import eslintConfigPrettier from 'eslint-config-prettier';
5+
import reactPlugin from 'eslint-plugin-react';
6+
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
7+
import globals from 'globals';
8+
import tsEslint from 'typescript-eslint';
9+
import { fileURLToPath } from 'url';
10+
11+
const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url));
12+
13+
export default tsEslint.config(
14+
// register all of the plugins up-front
15+
{
16+
plugins: {
17+
'@typescript-eslint': tsEslint.plugin,
18+
// @ts-expect-error https://github.com/jsx-eslint/eslint-plugin-react/issues/3699
19+
react: fixupPluginRules(reactPlugin),
20+
'simple-import-sort': simpleImportSortPlugin
21+
}
22+
},
23+
// config with just ignores is the replacement for `.eslintignore`
24+
{ ignores: ['**/node_modules/**', '**/dist/**', '**/.parcel-cache/**'] },
25+
26+
// extends ...
27+
eslint.configs.recommended,
28+
...tsEslint.configs.recommended,
29+
30+
// base config
31+
{
32+
languageOptions: {
33+
globals: { ...globals.es2020, ...globals.browser, ...globals.node },
34+
parserOptions: {
35+
projectService: true,
36+
tsconfigRootDir,
37+
warnOnUnsupportedTypeScriptVersion: false
38+
}
39+
},
40+
rules: {
41+
'simple-import-sort/exports': 'error',
42+
'simple-import-sort/imports': 'error',
43+
'react/jsx-no-target-blank': 'warn',
44+
'react/jsx-sort-props': [
45+
'error',
46+
{
47+
reservedFirst: true,
48+
shorthandLast: true,
49+
callbacksLast: true,
50+
noSortAlphabetically: true
51+
}
52+
],
53+
'@typescript-eslint/no-unused-vars': 'warn',
54+
'@typescript-eslint/no-explicit-any': 'warn',
55+
'@typescript-eslint/no-empty-object-type': 'off',
56+
'@typescript-eslint/no-unsafe-declaration-merging': 'warn'
57+
}
58+
},
59+
{
60+
files: ['**/*.js'],
61+
extends: [tsEslint.configs.disableTypeChecked],
62+
rules: {
63+
// turn off other type-aware rules
64+
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
65+
66+
// turn off rules that don't apply to JS code
67+
'@typescript-eslint/explicit-function-return-type': 'off'
68+
}
69+
},
70+
eslintConfigPrettier
71+
);

package.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@
4747
"devDependencies": {
4848
"@babel/plugin-proposal-decorators": "^7.25.7",
4949
"@babel/preset-typescript": "^7.25.7",
50+
"@eslint/compat": "^1.2.0",
51+
"@eslint/js": "^9.12.0",
5052
"@microsoft/api-extractor": "^7.47.11",
5153
"@parcel/config-default": "~2.12.0",
5254
"@parcel/packager-ts": "~2.12.0",
5355
"@parcel/transformer-less": "2.12.0",
5456
"@parcel/transformer-typescript-tsc": "~2.12.0",
5557
"@parcel/transformer-typescript-types": "~2.12.0",
58+
"@softonus/prettier-plugin-duplicate-remover": "^1.0.1",
5659
"@storybook/addon-console": "^3.0.0",
5760
"@storybook/addon-essentials": "^7.6.20",
5861
"@storybook/addon-interactions": "^7.6.20",
@@ -67,20 +70,20 @@
6770
"@types/prismjs": "^1.26.4",
6871
"@types/react": "^18.3.11",
6972
"@types/react-dom": "^18.3.1",
70-
"@typescript-eslint/eslint-plugin": "^8.10.0",
71-
"@typescript-eslint/parser": "^8.10.0",
7273
"@vitejs/plugin-react": "^4.3.2",
73-
"eslint": "^8.57.1",
74+
"eslint": "^9.12.0",
7475
"eslint-config-prettier": "^9.1.0",
75-
"eslint-plugin-import": "^2.31.0",
76+
"eslint-plugin-react": "^7.37.1",
7677
"eslint-plugin-simple-import-sort": "^12.1.1",
78+
"globals": "^15.11.0",
7779
"husky": "^9.1.6",
7880
"koapache": "^2.2.2",
7981
"less": "^4.2.0",
8082
"lint-staged": "^15.2.10",
8183
"parcel": "~2.12.0",
8284
"postcss-preset-env": "^10.0.7",
8385
"prettier": "^3.3.3",
86+
"prettier-plugin-css-order": "^2.1.2",
8487
"process": "^0.11.10",
8588
"prop-types": "15.8.1",
8689
"react": "^18.3.1",
@@ -90,17 +93,22 @@
9093
"typedoc": "^0.26.10",
9194
"typedoc-plugin-mdn-links": "^3.3.3",
9295
"typescript": "~5.6.3",
96+
"typescript-eslint": "^8.10.0",
9397
"vite": "^5.4.9"
9498
},
9599
"prettier": {
96100
"singleQuote": true,
97101
"trailingComma": "none",
98102
"arrowParens": "avoid",
99-
"tabWidth": 4
103+
"tabWidth": 4,
104+
"plugins": [
105+
"prettier-plugin-css-order",
106+
"@softonus/prettier-plugin-duplicate-remover"
107+
]
100108
},
101109
"lint-staged": {
102-
"*.{md,less,json,yml,ts,tsx}": "prettier --write",
103-
"*.{js,jsx,ts,tsx}": "eslint --fix"
110+
"*.{md,less,json,yml,js,mjs,ts,tsx}": "prettier --write",
111+
"*.{js,ts,tsx}": "eslint --fix"
104112
},
105113
"browserslist": "> 0.5%, last 2 versions, not dead, IE 11",
106114
"targets": {

0 commit comments

Comments
 (0)