@orderly.network/eslint-config 0.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,4 @@
1
+ include:
2
+ - project: "orderlynetwork/orderly-fe/js-sdks/common-ci"
3
+ ref: main
4
+ file: "/npm-release.yml"
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # README
package/index.mjs ADDED
@@ -0,0 +1,190 @@
1
+ import stylistic from "@stylistic/eslint-plugin";
2
+ import eslintConfigPrettier from "eslint-config-prettier/flat";
3
+ // import importPlugin from "eslint-plugin-import";
4
+ import monorepoCop from "eslint-plugin-monorepo-cop";
5
+ import reactPlugin from "eslint-plugin-react";
6
+ import * as reactHooks from "eslint-plugin-react-hooks";
7
+ import reactRefresh from "eslint-plugin-react-refresh";
8
+ import tailwind from "eslint-plugin-tailwindcss";
9
+ import { defineConfig, globalIgnores } from "eslint/config";
10
+ import globals from "globals";
11
+ import path from "path";
12
+ import ts from "typescript-eslint";
13
+ import { fileURLToPath } from "url";
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = path.dirname(__filename);
17
+
18
+ export default defineConfig([
19
+ globalIgnores([
20
+ "**/build/",
21
+ "**/dist/",
22
+ "**/node_modules/",
23
+ "**/public/",
24
+ "**/__test__/",
25
+ "**/storybook-static/",
26
+ "**/*.js",
27
+ "**/*.cjs",
28
+ "**/*.d.ts",
29
+ ]),
30
+ {
31
+ languageOptions: {
32
+ // parser: typescriptEslintParser,
33
+ parserOptions: {
34
+ ecmaFeatures: {
35
+ jsx: true,
36
+ },
37
+ },
38
+ globals: {
39
+ ...globals.browser,
40
+ },
41
+ },
42
+ },
43
+ // add eslint built-in
44
+ // https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js
45
+ // js.configs.recommended,
46
+
47
+ // add `typescript-eslint` flat config simply
48
+ // if you would like use more another configuration,
49
+ // see the section: https://typescript-eslint.io/getting-started#details
50
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslintrc/recommended.ts
51
+ ...ts.configs.recommended,
52
+
53
+ // https://github.com/francoismassart/eslint-plugin-tailwindcss
54
+ // https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/lib/config/flat-recommended.js
55
+ ...tailwind.configs["flat/recommended"],
56
+
57
+ // https://github.com/vercel/turborepo/blob/main/packages/eslint-config-turbo/src/flat/index.ts
58
+ // ...turboConfig,
59
+
60
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/index.js#L108
61
+ reactPlugin.configs.flat.recommended,
62
+ // Add this if you are using React 17+
63
+ reactPlugin.configs.flat["jsx-runtime"],
64
+
65
+ // https://github.com/import-js/eslint-plugin-import
66
+ // importPlugin.flatConfigs.recommended,
67
+ // use custom config instead of importPlugin.flatConfigs.recommended, because it's too strict for our project
68
+ // {
69
+ // plugins: {
70
+ // import: importPlugin,
71
+ // },
72
+ // rules: {
73
+ // "import/no-relative-packages": "error",
74
+ // // analysis/correctness
75
+ // "import/no-unresolved": "warn",
76
+ // "import/named": "warn",
77
+ // "import/namespace": "warn",
78
+ // "import/default": "warn",
79
+ // "import/export": "warn",
80
+
81
+ // // red flags (thus, warnings)
82
+ // "import/no-named-as-default": "warn",
83
+ // "import/no-named-as-default-member": "warn",
84
+ // "import/no-duplicates": "warn",
85
+ // },
86
+ // languageOptions: {
87
+ // // need all these for parsing dependencies (even if _your_ code doesn't need
88
+ // // all of them)
89
+ // parserOptions: {
90
+ // sourceType: "module",
91
+ // ecmaVersion: 2018,
92
+ // },
93
+ // },
94
+ // },
95
+ {
96
+ files: ["**/*.{ts,tsx}"],
97
+ // ignores: ["dist/**", "build/**", "node_modules/**"],
98
+ plugins: {
99
+ // https://eslint.style/packages/default
100
+ "@stylistic": stylistic,
101
+ "monorepo-cop": monorepoCop,
102
+ "react-hooks": reactHooks,
103
+ "react-refresh": reactRefresh,
104
+ },
105
+ rules: {
106
+ "no-console": ["warn", { allow: ["warn", "error"] }],
107
+ // "@stylistic/semi": ["error", "never"],
108
+ "prefer-const": "warn",
109
+ "@typescript-eslint/no-unused-expressions": "warn",
110
+ "@typescript-eslint/no-explicit-any": "warn",
111
+ "@typescript-eslint/no-unused-vars": "warn",
112
+ "@typescript-eslint/ban-ts-comment": "warn",
113
+ "@typescript-eslint/no-empty-object-type": "warn",
114
+ "@typescript-eslint/no-unused-vars": "warn",
115
+ "@typescript-eslint/no-unnecessary-type-constraint": "warn",
116
+ "@typescript-eslint/no-empty-object-type": "warn",
117
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
118
+ "@typescript-eslint/no-namespace": "warn",
119
+ "@typescript-eslint/ban-ts-comment": "off",
120
+ "react/prop-types": "off",
121
+ "react/display-name": "off",
122
+ "react/no-children-prop": "warn",
123
+ "tailwindcss/no-custom-classname": "off",
124
+
125
+ // https://github.com/sterlingwes/eslint-plugin-monorepo-cop
126
+ // prevent relative imports outside of monorepo package
127
+ "monorepo-cop/no-relative-import-outside-package": "error",
128
+ "monorepo-cop/no-disable-monorepo-no-relative-rule": "error",
129
+
130
+ // Core hooks rules
131
+ // https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks#flat-config-eslintconfigjsts-1
132
+ "react-hooks/rules-of-hooks": "warn",
133
+ // it cause too many false positives, use eslint-plugin-react-hooks-configurable won't solve the problem either
134
+ "react-hooks/exhaustive-deps": "warn",
135
+
136
+ // React Compiler rules
137
+ "react-hooks/config": "warn",
138
+ "react-hooks/error-boundaries": "warn",
139
+ "react-hooks/component-hook-factories": "warn",
140
+ "react-hooks/gating": "warn",
141
+ "react-hooks/globals": "warn",
142
+ "react-hooks/immutability": "warn",
143
+ "react-hooks/preserve-manual-memoization": "warn",
144
+ "react-hooks/purity": "warn",
145
+ "react-hooks/refs": "warn",
146
+ "react-hooks/set-state-in-effect": "warn",
147
+ "react-hooks/set-state-in-render": "error",
148
+ "react-hooks/static-components": "warn",
149
+ "react-hooks/unsupported-syntax": "warn",
150
+ "react-hooks/use-memo": "warn",
151
+ "react-hooks/incompatible-library": "warn",
152
+
153
+ // https://github.com/ArnaudBarre/eslint-plugin-react-refresh?tab=readme-ov-file#without-config
154
+ "react-refresh/only-export-components": [
155
+ "warn",
156
+ { allowConstantExport: true },
157
+ ],
158
+ },
159
+ },
160
+
161
+ eslintConfigPrettier,
162
+ {
163
+ settings: {
164
+ react: {
165
+ version: "18.2",
166
+ },
167
+ // https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules
168
+ tailwindcss: {
169
+ callees: ["classnames", "cnBase", "cn"],
170
+ config: path.resolve(__dirname, "../ui/tailwind.config.js"),
171
+ // default
172
+ cssFiles: [
173
+ "**/*.css",
174
+ "!**/node_modules",
175
+ "!**/.*",
176
+ "!**/dist",
177
+ "!**/build",
178
+ ],
179
+ cssFilesRefreshRate: 5_000,
180
+ removeDuplicates: true,
181
+ skipClassAttribute: false,
182
+ whitelist: [],
183
+ // can be set to e.g. ['tw'] for use in tw`bg-blue`
184
+ tags: [],
185
+ // can be modified to support custom attributes. E.g. "^tw$" for `twin.macro`
186
+ classRegex: "^class(Name)?$",
187
+ },
188
+ },
189
+ },
190
+ ]);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@orderly.network/eslint-config",
3
+ "version": "0.0.2-alpha.0",
4
+ "main": "index.mjs",
5
+ "module": "index.mjs",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "release": "orderly-npm-release"
12
+ },
13
+ "dependencies": {
14
+ "@eslint/js": "^9.39.2",
15
+ "@stylistic/eslint-plugin": "^5.7.0",
16
+ "eslint-config-eslint": "13.0.0",
17
+ "eslint-config-prettier": "^10.1.8",
18
+ "eslint-plugin-monorepo-cop": "^1.0.2",
19
+ "eslint-plugin-react": "^7.37.5",
20
+ "eslint-plugin-react-hooks": "^7.0.1",
21
+ "eslint-plugin-react-refresh": "^0.4.26",
22
+ "eslint-plugin-tailwindcss": "^3.18.2",
23
+ "globals": "^17.0.0",
24
+ "typescript-eslint": "^8.53.1"
25
+ },
26
+ "devDependencies": {
27
+ "@orderly.network/npm-release": "^0.0.6"
28
+ }
29
+ }