@ciridae/configs 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # @ciridae/configs
2
+
3
+ ## 0.1.0
4
+
5
+ - Publish shared ESLint, Prettier, and TypeScript configurations with explicit subpath exports.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @ciridae/configs
2
+
3
+ Shared frontend configuration for Ciridae projects.
4
+
5
+ ## ESLint
6
+
7
+ ```js
8
+ import { strictReactAppConfig } from "@ciridae/configs/eslint"
9
+
10
+ export default strictReactAppConfig()
11
+ ```
12
+
13
+ ## Prettier
14
+
15
+ ```js
16
+ export { default } from "@ciridae/configs/prettier" with { type: "json" }
17
+ ```
18
+
19
+ ## TypeScript
20
+
21
+ ```json
22
+ {
23
+ "extends": "@ciridae/configs/tsconfig/frontend-app.json"
24
+ }
25
+ ```
package/eslint.js ADDED
@@ -0,0 +1,192 @@
1
+ import { fixupPluginRules } from "@eslint/compat";
2
+ import js from "@eslint/js";
3
+ import importPlugin from "eslint-plugin-import";
4
+ import react from "eslint-plugin-react";
5
+ import globals from "globals";
6
+ import reactHooks from "eslint-plugin-react-hooks";
7
+ import legacyReactHooks from "eslint-plugin-react-hooks-legacy";
8
+ import reactRefresh from "eslint-plugin-react-refresh";
9
+ import legacyReactRefresh from "eslint-plugin-react-refresh-legacy";
10
+ import tailwindcss from "eslint-plugin-tailwindcss";
11
+ import legacyTailwindcss from "eslint-plugin-tailwindcss-legacy";
12
+ import tseslint from "typescript-eslint";
13
+
14
+ const typeAssertionBan = [
15
+ {
16
+ selector:
17
+ "TSAsExpression:not([typeAnnotation.type='TSTypeReference'][typeAnnotation.typeName.name='const'])",
18
+ message:
19
+ "Type assertions are banned. Prefer narrowing, parser/schema validation, or an eslint-disable with justification.",
20
+ },
21
+ {
22
+ selector: "TSTypeAssertion",
23
+ message:
24
+ "Type assertions are banned. Prefer narrowing, parser/schema validation, or an eslint-disable with justification.",
25
+ },
26
+ ];
27
+
28
+ export function reactAppConfig({ ignores = ["dist"], rules = {} } = {}) {
29
+ return tseslint.config(
30
+ { ignores },
31
+ {
32
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
33
+ files: ["**/*.{ts,tsx}"],
34
+ languageOptions: {
35
+ ecmaVersion: 2020,
36
+ globals: globals.browser,
37
+ },
38
+ plugins: {
39
+ "react-hooks": legacyReactHooks,
40
+ "react-refresh": legacyReactRefresh,
41
+ },
42
+ rules: {
43
+ ...legacyReactHooks.configs.recommended.rules,
44
+ "react-refresh/only-export-components": [
45
+ "warn",
46
+ { allowConstantExport: true },
47
+ ],
48
+ "@typescript-eslint/no-unused-vars": "off",
49
+ ...rules,
50
+ },
51
+ },
52
+ );
53
+ }
54
+
55
+ export function legacyStrictReactAppConfig(options = {}) {
56
+ return createStrictReactAppConfig(options, {
57
+ reactHooks: legacyReactHooks,
58
+ reactRefresh: legacyReactRefresh,
59
+ tailwindcss: legacyTailwindcss,
60
+ });
61
+ }
62
+
63
+ export function strictReactAppConfig(options = {}) {
64
+ return createStrictReactAppConfig(options, {
65
+ reactHooks,
66
+ reactRefresh,
67
+ tailwindcss,
68
+ });
69
+ }
70
+
71
+ function createStrictReactAppConfig(
72
+ {
73
+ ignores = ["dist"],
74
+ tsconfigRootDir,
75
+ maxLines = 300,
76
+ maxLinesPerFunction = 80,
77
+ tailwindCssFiles,
78
+ rules = {},
79
+ settings = {},
80
+ testFiles = ["**/*.test.{ts,tsx}", "**/test/**/*.{ts,tsx}"],
81
+ overrides = [],
82
+ } = {},
83
+ policyPlugins,
84
+ ) {
85
+ const plugins = {
86
+ import: fixupPluginRules(importPlugin),
87
+ react: fixupPluginRules(react),
88
+ "react-hooks": policyPlugins.reactHooks,
89
+ "react-refresh": policyPlugins.reactRefresh,
90
+ tailwindcss: fixupPluginRules(policyPlugins.tailwindcss),
91
+ };
92
+
93
+ return tseslint.config(
94
+ { ignores },
95
+ {
96
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
97
+ files: ["**/*.{ts,tsx}"],
98
+ languageOptions: {
99
+ ecmaVersion: 2020,
100
+ globals: globals.browser,
101
+ parserOptions: {
102
+ ecmaFeatures: {
103
+ jsx: true,
104
+ },
105
+ projectService: true,
106
+ tsconfigRootDir,
107
+ },
108
+ },
109
+ plugins,
110
+ rules: {
111
+ ...plugins["react-hooks"].configs.recommended.rules,
112
+ "@typescript-eslint/no-explicit-any": "error",
113
+ "@typescript-eslint/no-non-null-assertion": "error",
114
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
115
+ "@typescript-eslint/no-unused-vars": "error",
116
+ "@typescript-eslint/no-unsafe-argument": "error",
117
+ "@typescript-eslint/no-unsafe-assignment": "error",
118
+ "@typescript-eslint/no-unsafe-call": "error",
119
+ "@typescript-eslint/no-unsafe-member-access": "error",
120
+ "@typescript-eslint/no-unsafe-return": "error",
121
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
122
+ complexity: ["error", 12],
123
+ "import/no-cycle": "error",
124
+ "import/no-self-import": "error",
125
+ "max-depth": ["error", 3],
126
+ "max-lines": [
127
+ "error",
128
+ { max: maxLines, skipBlankLines: true, skipComments: true },
129
+ ],
130
+ "max-lines-per-function": [
131
+ "error",
132
+ {
133
+ max: maxLinesPerFunction,
134
+ skipBlankLines: true,
135
+ skipComments: true,
136
+ },
137
+ ],
138
+ "max-nested-callbacks": ["error", 3],
139
+ "max-params": ["error", 4],
140
+ "no-restricted-syntax": ["error", ...typeAssertionBan],
141
+ "react/jsx-max-depth": ["error", { max: 4 }],
142
+ "react/jsx-no-constructed-context-values": "error",
143
+ "react/no-unstable-nested-components": "error",
144
+ "react-refresh/only-export-components": [
145
+ "warn",
146
+ { allowConstantExport: true },
147
+ ],
148
+ ...rules,
149
+ },
150
+ settings: {
151
+ "import/extensions": [".js", ".jsx", ".ts", ".tsx"],
152
+ "import/parsers": {
153
+ "@typescript-eslint/parser": [".ts", ".tsx"],
154
+ },
155
+ "import/resolver": {
156
+ node: {
157
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
158
+ },
159
+ },
160
+ react: {
161
+ version: "detect",
162
+ },
163
+ ...(tailwindCssFiles
164
+ ? {
165
+ tailwindcss: {
166
+ config: {},
167
+ cssFiles: tailwindCssFiles,
168
+ },
169
+ }
170
+ : {}),
171
+ ...settings,
172
+ },
173
+ },
174
+ {
175
+ files: testFiles,
176
+ rules: {
177
+ "@typescript-eslint/no-unsafe-call": "off",
178
+ "@typescript-eslint/no-unsafe-member-access": "off",
179
+ "@typescript-eslint/no-unsafe-assignment": "off",
180
+ "@typescript-eslint/no-unsafe-argument": "off",
181
+ "@typescript-eslint/no-unsafe-return": "off",
182
+ "@typescript-eslint/no-explicit-any": "off",
183
+ "@typescript-eslint/no-non-null-assertion": "off",
184
+ "no-restricted-syntax": "off",
185
+ "max-lines-per-function": "off",
186
+ "max-lines": "off",
187
+ "max-nested-callbacks": "off",
188
+ },
189
+ },
190
+ ...overrides,
191
+ );
192
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@ciridae/configs",
3
+ "version": "0.1.0",
4
+ "description": "Shared ESLint, Prettier, and TypeScript configurations for Ciridae projects.",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.18"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ciridae-ai/ciridae.git",
12
+ "directory": "packages/configs"
13
+ },
14
+ "homepage": "https://github.com/ciridae-ai/ciridae#readme",
15
+ "files": [
16
+ "CHANGELOG.md",
17
+ "eslint.js",
18
+ "prettier.json",
19
+ "tsconfig"
20
+ ],
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ "./eslint": "./eslint.js",
24
+ "./prettier": "./prettier.json",
25
+ "./tsconfig/frontend-app.json": "./tsconfig/frontend-app.json",
26
+ "./tsconfig/frontend-node.json": "./tsconfig/frontend-node.json"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "dependencies": {
32
+ "@eslint/compat": "^2.1.0",
33
+ "@eslint/js": "^9.9.0",
34
+ "eslint-plugin-import": "^2.32.0",
35
+ "eslint-plugin-react": "^7.37.5",
36
+ "eslint-plugin-react-hooks": "^7.1.1",
37
+ "eslint-plugin-react-hooks-legacy": "npm:eslint-plugin-react-hooks@^5.1.0-rc.0",
38
+ "eslint-plugin-react-refresh": "^0.5.3",
39
+ "eslint-plugin-react-refresh-legacy": "npm:eslint-plugin-react-refresh@^0.4.9",
40
+ "eslint-plugin-tailwindcss": "4.0.5",
41
+ "eslint-plugin-tailwindcss-legacy": "npm:eslint-plugin-tailwindcss@^4.0.0-alpha.2",
42
+ "globals": "^15.9.0",
43
+ "typescript-eslint": "^8.0.1"
44
+ },
45
+ "peerDependencies": {
46
+ "eslint": "^9.9.0 || ^10.0.0"
47
+ }
48
+ }
package/prettier.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "tabWidth": 2,
3
+ "useTabs": true,
4
+ "semi": false,
5
+ "singleQuote": false,
6
+ "trailingComma": "es5",
7
+ "printWidth": 100,
8
+ "bracketSpacing": true,
9
+ "arrowParens": "always",
10
+ "endOfLine": "lf"
11
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "strict": true,
9
+
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ "noUnusedLocals": false,
18
+ "noUnusedParameters": false,
19
+ "noFallthroughCasesInSwitch": false
20
+ }
21
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2023"],
5
+ "module": "ESNext",
6
+ "skipLibCheck": true,
7
+
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "isolatedModules": true,
11
+ "moduleDetection": "force",
12
+ "noEmit": true,
13
+
14
+ "strict": true,
15
+ "noUnusedLocals": false,
16
+ "noUnusedParameters": false,
17
+ "noFallthroughCasesInSwitch": true
18
+ }
19
+ }