Skip to content

Commit ec5bf05

Browse files
authored
Lint format checks (#225)
* Add a lint action to Github Actions * Add import sorting plugin * Format files and add check * Run eslint autofix * Autofix unused imports * Autofix import issues * Resolve additional formatting errors * Lock TS version to minor release * Skip env validation in CI, add typecheck
1 parent 1841b8e commit ec5bf05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5532
-4982
lines changed

.eslintrc.cjs

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,89 @@
11
/** @type {import("eslint").Linter.Config} */
22
const config = {
3-
parser: "@typescript-eslint/parser",
3+
parser: '@typescript-eslint/parser',
44
parserOptions: {
55
project: true,
6+
sourceType: 'module',
67
},
7-
plugins: ["@typescript-eslint"],
8+
plugins: ['@typescript-eslint', 'import', 'unused-imports'],
89
extends: [
9-
"next/core-web-vitals",
10-
"plugin:@typescript-eslint/recommended-type-checked",
11-
"plugin:@typescript-eslint/stylistic-type-checked",
10+
'next/core-web-vitals',
11+
'plugin:@typescript-eslint/recommended-type-checked',
12+
'plugin:@typescript-eslint/stylistic-type-checked',
13+
'plugin:import/recommended',
14+
'plugin:import/typescript',
1215
],
16+
settings: {
17+
'import/resolver': {
18+
typescript: {
19+
project: './tsconfig.json',
20+
},
21+
},
22+
},
1323
rules: {
1424
// These opinionated rules are enabled in stylistic-type-checked above.
1525
// Feel free to reconfigure them to your own preference.
16-
"@typescript-eslint/array-type": "off",
17-
"@typescript-eslint/consistent-type-definitions": "off",
26+
'@typescript-eslint/array-type': 'off',
27+
'@typescript-eslint/consistent-type-definitions': 'off',
1828

19-
"@typescript-eslint/consistent-type-imports": [
20-
"warn",
29+
'@typescript-eslint/consistent-type-imports': [
30+
'warn',
2131
{
22-
prefer: "type-imports",
23-
fixStyle: "inline-type-imports",
32+
prefer: 'type-imports',
33+
fixStyle: 'inline-type-imports',
2434
},
2535
],
26-
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
27-
"@typescript-eslint/require-await": "off",
28-
"@typescript-eslint/no-misused-promises": [
29-
"error",
36+
'@typescript-eslint/no-unused-vars': 'off',
37+
'@typescript-eslint/require-await': 'off',
38+
'@typescript-eslint/no-misused-promises': [
39+
'error',
3040
{
3141
checksVoidReturn: { attributes: false },
3242
},
3343
],
44+
'sort-imports': [
45+
'error',
46+
{
47+
ignoreCase: false,
48+
ignoreDeclarationSort: true,
49+
ignoreMemberSort: false,
50+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
51+
allowSeparatedGroups: true,
52+
},
53+
],
54+
'import/no-unresolved': 'error',
55+
// 'import/no-named-as-default-member': 'off',
56+
'import/order': [
57+
'error',
58+
{
59+
groups: [
60+
'builtin', // Built-in imports (come from NodeJS native) go first
61+
'external', // <- External imports
62+
'internal', // <- Absolute imports
63+
['sibling', 'parent'], // <- Relative imports, the sibling and parent types they can be mingled together
64+
'index', // <- index imports
65+
'unknown', // <- unknown
66+
],
67+
'newlines-between': 'always',
68+
alphabetize: {
69+
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
70+
order: 'asc',
71+
/* ignore case. Options: [true, false] */
72+
caseInsensitive: true,
73+
},
74+
},
75+
],
76+
'unused-imports/no-unused-imports': 'error',
77+
'unused-imports/no-unused-vars': [
78+
'warn',
79+
{
80+
vars: 'all',
81+
varsIgnorePattern: '^_',
82+
args: 'after-used',
83+
argsIgnorePattern: '^_',
84+
},
85+
],
86+
'import/no-named-as-default': 'off',
3487
},
3588
};
3689

.github/workflows/check.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Check
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
check:
9+
runs-on: ubuntu-latest
10+
env:
11+
SKIP_ENV_VALIDATION: true
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- uses: pnpm/action-setup@v4
18+
name: Install pnpm
19+
with:
20+
run_install: false
21+
22+
- name: Install Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 18
26+
cache: 'pnpm'
27+
28+
- name: Install dependencies
29+
run: pnpm install
30+
31+
- name: Check code formatting
32+
run: pnpm prettier --check .
33+
34+
- name: Run lint
35+
run: pnpm lint
36+
37+
- name: Run tsc
38+
run: pnpm tsc --noEmit

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm-lock.yaml

components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
"components": "~/components",
1515
"utils": "~/lib/utils"
1616
}
17-
}
17+
}

docker/prod/compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@ services:
5757

5858
volumes:
5959
database:
60-

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,21 @@
8585
"@types/react": "^18.2.37",
8686
"@types/react-dom": "^18.2.15",
8787
"@types/web-push": "^3.6.3",
88-
"@typescript-eslint/eslint-plugin": "^6.11.0",
89-
"@typescript-eslint/parser": "^6.11.0",
88+
"@typescript-eslint/eslint-plugin": "^6.19.0",
89+
"@typescript-eslint/parser": "^6.19.0",
9090
"autoprefixer": "^10.4.14",
91-
"eslint": "^8.54.0",
91+
"eslint": "^8.56.0",
9292
"eslint-config-next": "^14.0.4",
93+
"eslint-import-resolver-typescript": "^4.3.5",
94+
"eslint-plugin-import": "^2.31.0",
95+
"eslint-plugin-unused-imports": "^3.2.0",
9396
"postcss": "^8.4.31",
94-
"prettier": "^3.1.0",
97+
"prettier": "^3.2.4",
9598
"prettier-plugin-tailwindcss": "^0.5.7",
9699
"prisma": "^5.9.1",
97100
"tailwindcss": "^3.3.5",
98101
"tsx": "^4.7.1",
99-
"typescript": "^5.1.6"
102+
"typescript": "~5.1.6"
100103
},
101104
"ct3aMetadata": {
102105
"initVersion": "7.25.2"
@@ -105,4 +108,4 @@
105108
"seed": "tsx prisma/seed.ts"
106109
},
107110
"packageManager": "[email protected]"
108-
}
111+
}

0 commit comments

Comments
 (0)