Skip to content

Commit 6d8ea68

Browse files
committed
chore: add more eslint rules
1 parent b037e92 commit 6d8ea68

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

.husky/pre-push

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
pnpm lint

eslint.config.js

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import pluginJs from "@eslint/js";
33
import tseslint from "typescript-eslint";
44
import pluginReact from "eslint-plugin-react";
55
import eslintPluginPrettier from "eslint-plugin-prettier";
6+
import importPlugin from "eslint-plugin-import";
7+
import { fileURLToPath } from "url";
8+
import { dirname } from "path";
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = dirname(__filename);
612

713
/** @type {import('eslint').Linter.Config[]} */
814
export default [
@@ -12,20 +18,61 @@ export default [
1218
...tseslint.configs.recommended,
1319
pluginReact.configs.flat.recommended,
1420
{
21+
languageOptions: {
22+
parserOptions: {
23+
project: "./tsconfig.json",
24+
tsconfigRootDir: __dirname,
25+
},
26+
},
1527
settings: {
1628
react: {
1729
version: "detect",
1830
},
1931
},
2032
plugins: {
2133
prettier: eslintPluginPrettier,
34+
import: importPlugin,
2235
},
2336
rules: {
2437
"prettier/prettier": "error",
2538
"react/react-in-jsx-scope": "off",
39+
"@typescript-eslint/naming-convention": [
40+
"error",
41+
{
42+
selector: "interface",
43+
format: ["PascalCase"],
44+
},
45+
],
46+
"react/function-component-definition": [
47+
2,
48+
{
49+
namedComponents: "function-declaration",
50+
},
51+
],
52+
"no-console": "error",
53+
"import/order": 2,
54+
"no-nested-ternary": 2,
55+
"@typescript-eslint/consistent-type-imports": [
56+
"error",
57+
{
58+
prefer: "type-imports",
59+
},
60+
],
61+
"dot-notation": "off",
62+
"@typescript-eslint/dot-notation": "error",
2663
},
2764
},
2865
{
29-
ignores: ["dist/", "node_modules/**/*"],
66+
ignores: [
67+
"dist/",
68+
"node_modules/**/*",
69+
".storybook",
70+
"commitlint.config.mjs",
71+
"**/*.stories.tsx",
72+
"copy-types.js",
73+
"**/*.config.js",
74+
"vite.config.ts",
75+
"generate-exports.js",
76+
],
3077
},
3178
];

src/badge/Badge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cva } from "class-variance-authority";
2+
import type { ReactElement } from "react";
23
import { cn } from "../tw-merge";
3-
import { Avatar } from "../avatar";
4-
import { ReactElement } from "react";
4+
import type { Avatar } from "../avatar";
55

66
const badge = cva(
77
"flex items-center justify-center overflow-hidden rounded-[100px] font-medium text-base-300",

0 commit comments

Comments
 (0)