Skip to content

Commit 706059c

Browse files
refactor(Lint): Centralize lint files
1 parent 9134f37 commit 706059c

File tree

10 files changed

+86
-77
lines changed

10 files changed

+86
-77
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module.exports = {
22
ignores: [
3-
(commit) => /^chore(\(main\))?: release \d+\.\d+\.\d+/.test(commit),
3+
function (commit) {
4+
return /^chore(\(main\))?: release \d+\.\d+\.\d+/.test(commit);
5+
},
46
],
57
extends: ['@commitlint/config-conventional'],
68
rules: {

.editorconfig renamed to .github/linters/.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ trim_trailing_whitespace = true
2929
# UTF-8 encoding
3030
charset = utf-8
3131

32-
# Use spaces for all indents with a width of 4 characters.
32+
# Use spaces for all indents with a width of 2 characters.
3333
indent_style = space
3434
indent_size = 2
3535

@@ -39,3 +39,4 @@ ij_typescript_use_double_quotes = false
3939

4040
[package*.json]
4141
indent_size = 2
42+

.github/linters/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
coverage/
2+
dist/
3+
storybook-static/
4+
tokens/
5+
CHANGELOG.md
File renamed without changes.

.github/linters/eslint.config.mjs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
2+
import { FlatCompat } from '@eslint/eslintrc';
3+
import js from '@eslint/js';
4+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
5+
import tsParser from '@typescript-eslint/parser';
6+
import { defineConfig, globalIgnores } from 'eslint/config';
7+
import globals from 'globals';
8+
import path from 'node:path';
9+
import { fileURLToPath } from 'node:url';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all,
17+
});
18+
19+
export default defineConfig(
20+
[globalIgnores(['storybook-static/', 'dist/', 'coverage/'])],
21+
[
22+
{
23+
extends: fixupConfigRules(
24+
compat.extends(
25+
'eslint:recommended',
26+
'plugin:react/recommended',
27+
'plugin:@typescript-eslint/recommended',
28+
'plugin:@typescript-eslint/eslint-recommended',
29+
'prettier',
30+
'plugin:prettier/recommended',
31+
'plugin:react-hooks/recommended',
32+
'plugin:storybook/recommended',
33+
),
34+
),
35+
36+
settings: {
37+
react: {
38+
version: 'detect',
39+
},
40+
},
41+
42+
plugins: {
43+
'@typescript-eslint': fixupPluginRules(typescriptEslint),
44+
},
45+
46+
languageOptions: {
47+
globals: {
48+
...globals.jest,
49+
...globals.browser,
50+
},
51+
52+
parser: tsParser,
53+
},
54+
55+
ignores: [
56+
'eslint.config.mjs',
57+
'vitest.config.js',
58+
'**/vendor/*.js',
59+
'CHANGELOG.md',
60+
],
61+
62+
rules: {
63+
'react/react-in-jsx-scope': 'off',
64+
'react/prop-types': 'off',
65+
},
66+
},
67+
],
68+
);

.github/workflows/commitlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
2828
- name: Validate PR commits with commitlint
2929
if: github.event_name == 'pull_request'
30-
run: npx commitlint -g .commitlintrc.ts --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
30+
run: npx commitlint -g .github/linters/.commitlintrc.ts --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

.husky/commit-msg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
npx commitlint -e $1 -g .commitlintrc.ts
1+
npx commitlint -e $1 -g .github/linters/.commitlintrc.ts
2+

.prettierignore

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

eslint.config.mjs

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

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@
7878
"build": "tsc && vite build",
7979
"build-storybook": "storybook build",
8080
"build-tokens": "tsx scripts/tokens.ts",
81-
"format": "prettier --write . '**/*.{ts,tsx,js,jsx,yml}'",
82-
"lint": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
81+
"format": "prettier --config .github/linters/.prettierrc --ignore-path .github/linters/.prettierignore --write . '**/*.{ts,tsx,js,jsx,yml}'",
82+
"lint": "eslint . --ext .ts,.tsx,.js,.jsx --fix --config .github/linters/eslint.config.mjs",
8383
"prepare": "husky"
8484
},
8585
"lint-staged": {
86-
"*.{js,jsx,ts,tsx}": [
87-
"prettier --write",
88-
"eslint --fix"
86+
"*{js,jsx,ts,tsx}": [
87+
"prettier --config .github/linters/.prettierrc --ignore-path .github/linters/.prettierignore --write",
88+
"eslint --fix --config .github/linters/eslint.config.mjs"
8989
]
9090
},
9191
"repository": {

0 commit comments

Comments
 (0)