@chencan-cnc/dev-config 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/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Consumer usage
2
+
3
+ Install pattern for each app repo
4
+
5
+ ```bash
6
+ pnpm add -D @chencan-cnc/dev-config eslint typescript
7
+ ```
8
+
9
+ If it is a Next app:
10
+
11
+ ```bash
12
+ pnpm add -D @chencan-cnc/dev-config eslint typescript eslint-config-next
13
+ ```
14
+
15
+ ### Generic TS service
16
+
17
+ ```javascript
18
+ // eslint.config.mjs
19
+ import { defineConfig } from "eslint/config";
20
+ import { base, typed } from "@chencan-cnc/dev-config";
21
+
22
+ export default defineConfig(base, typed, {
23
+ rules: {
24
+ "no-console": "off",
25
+ },
26
+ });
27
+ ```
28
+
29
+ ```json
30
+ {
31
+ "extends": "@chencan-cnc/dev-config/tsconfig/node-lib",
32
+ "compilerOptions": {
33
+ "outDir": "dist",
34
+ "rootDir": "src"
35
+ },
36
+ "include": ["src"]
37
+ }
38
+ ```
39
+
40
+ ### Next app
41
+
42
+ ```javascript
43
+ // eslint.config.mjs
44
+ import { defineConfig } from "eslint/config";
45
+ import { base, typed, next, tailwind } from "@chencan-cnc/dev-config";
46
+
47
+ export default defineConfig(base, typed, next, tailwind, {
48
+ settings: {
49
+ "better-tailwindcss": {
50
+ entryPoint: "src/app/globals.css",
51
+ },
52
+ },
53
+ });
54
+ ```
55
+
56
+ ```json
57
+ {
58
+ "extends": "@chencan-cnc/dev-config/tsconfig/next-app",
59
+ "compilerOptions": {
60
+ "baseUrl": ".",
61
+ "paths": {
62
+ "@/*": ["./src/*"]
63
+ }
64
+ },
65
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
66
+ "exclude": ["node_modules"]
67
+ }
68
+ ```
69
+
70
+ ### CRITICAL
@@ -0,0 +1,3 @@
1
+ declare const base: import("eslint/config").Config[];
2
+ export default base;
3
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/eslint/base.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,IAAI,kCA2ET,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,81 @@
1
+ import path from "node:path";
2
+ import commentsPlugin from "@eslint-community/eslint-plugin-eslint-comments";
3
+ import js from "@eslint/js";
4
+ import prettierConfig from "eslint-config-prettier/flat";
5
+ import { flatConfigs as importXFlatConfigs } from "eslint-plugin-import-x";
6
+ import prettierPlugin from "eslint-plugin-prettier";
7
+ import { configs as regexpConfigs } from "eslint-plugin-regexp";
8
+ import { configs as securityConfigs } from "eslint-plugin-security";
9
+ import { defineConfig } from "eslint/config";
10
+ import { configs as tsConfigs, parser as tsParser } from "typescript-eslint";
11
+ const base = defineConfig({
12
+ // Default ignores of eslint-config-next:
13
+ ignores: [
14
+ "**/node_modules/**",
15
+ "**/dist/**",
16
+ "**/build/**",
17
+ "**/coverage/**",
18
+ "**/.turbo/**",
19
+ "**/.next/**",
20
+ "tsconfig/**/*.json",
21
+ ],
22
+ }, {
23
+ // Default files:
24
+ files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
25
+ // Set Plugins
26
+ plugins: {
27
+ "eslint-comments": commentsPlugin,
28
+ prettier: prettierPlugin,
29
+ },
30
+ // Extend rule sets from:
31
+ extends: [
32
+ js.configs.recommended,
33
+ ...tsConfigs.recommended,
34
+ ...tsConfigs.stylistic,
35
+ importXFlatConfigs.recommended,
36
+ importXFlatConfigs.typescript,
37
+ regexpConfigs["flat/recommended"],
38
+ securityConfigs.recommended,
39
+ // Override default ignores of eslint-config-next.
40
+ // keep last
41
+ prettierConfig,
42
+ ],
43
+ // Configure language/parsing options
44
+ languageOptions: {
45
+ ecmaVersion: "latest",
46
+ sourceType: "module",
47
+ // Use TypeScript ESLint parser for TypeScript files
48
+ parser: tsParser,
49
+ parserOptions: {
50
+ // Enable project service for better TypeScript integration
51
+ projectService: true,
52
+ // import.meta.dirname is src/eslint; tsconfig lives at repo root
53
+ tsconfigRootDir: path.resolve(import.meta.dirname, "..", ".."),
54
+ },
55
+ },
56
+ // Configure rules
57
+ rules: {
58
+ "no-debugger": "error",
59
+ "no-console": ["warn", { allow: ["warn", "error"] }],
60
+ "eslint-comments/no-unused-disable": "error",
61
+ "eslint-comments/require-description": "warn",
62
+ "import-x/first": "error",
63
+ "import-x/newline-after-import": "error",
64
+ "import-x/no-duplicates": "error",
65
+ "import-x/no-self-import": "error",
66
+ "import-x/no-mutable-exports": "error",
67
+ "regexp/no-dupe-characters-character-class": "error",
68
+ "regexp/no-obscure-range": "error",
69
+ "regexp/prefer-regexp-test": "error",
70
+ "security/detect-object-injection": "off",
71
+ "prettier/prettier": [
72
+ "error",
73
+ {},
74
+ {
75
+ usePrettierrc: true,
76
+ },
77
+ ],
78
+ },
79
+ });
80
+ export default base;
81
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/eslint/base.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,cAAc,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7E,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EtC,2CAA2C,EAAE,OAAO;QACpD,yBAAyB,EAAE,OAAO;QAClC,2BAA2B,EAAE,OAAO;QAEpC,kCAAkC,EAAE,KAAK;QAEzC,mBAAmB,EAAE;YACnB,OAAO;YACP,EAAE;YACF;gBACE,aAAa,EAAE,IAAI;aACpB;SACF;KACF;CACF,CACF,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { default as base } from "./base.js";
2
+ export { default as next } from "./next.js";
3
+ export { default as tailwind } from "./tailwind.js";
4
+ export { default as typed } from "./typed.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { default as base } from "./base.js";
2
+ export { default as next } from "./next.js";
3
+ export { default as tailwind } from "./tailwind.js";
4
+ export { default as typed } from "./typed.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const next: import("eslint/config").Config[];
2
+ export default next;
3
+ //# sourceMappingURL=next.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../src/eslint/next.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,IAAI,kCAER,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -0,0 +1,7 @@
1
+ import nextVitals from "eslint-config-next/core-web-vitals";
2
+ import { defineConfig } from "eslint/config";
3
+ const next = defineConfig(...nextVitals, {
4
+ ignores: ["next-env.d.ts", "out/**"],
5
+ });
6
+ export default next;
7
+ //# sourceMappingURL=next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/eslint/next.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,UAAU,EAAE;IACvC,OAAO,EAAE,CAAC,eAAe,EAAE,QAAQ,CAAC;CACrC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const tailwind: import("eslint/config").Config[];
2
+ export default tailwind;
3
+ //# sourceMappingURL=tailwind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../src/eslint/tailwind.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,QAAQ,kCAMZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import betterTailwindcss from "eslint-plugin-better-tailwindcss";
2
+ import { defineConfig } from "eslint/config";
3
+ const tailwind = defineConfig({
4
+ files: ["**/*.{jsx,tsx,html}"],
5
+ plugins: {
6
+ "better-tailwindcss": betterTailwindcss,
7
+ },
8
+ extends: [betterTailwindcss.configs.recommended],
9
+ });
10
+ export default tailwind;
11
+ //# sourceMappingURL=tailwind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../src/eslint/tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,QAAQ,GAAG,YAAY,CAAC;IAC5B,KAAK,EAAE,CAAC,qBAAqB,CAAC;IAC9B,OAAO,EAAE;QACP,oBAAoB,EAAE,iBAAiB;KACxC;IACD,OAAO,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC;CACjD,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const typed: import("eslint/config").Config[];
2
+ export default typed;
3
+ //# sourceMappingURL=typed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/eslint/typed.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,KAAK,kCA0BT,CAAC;AAEH,eAAe,KAAK,CAAC"}
@@ -0,0 +1,33 @@
1
+ import path from "node:path";
2
+ import { defineConfig } from "eslint/config";
3
+ import { configs as tseslintConfigs } from "typescript-eslint";
4
+ const tsconfigRootDir = path.resolve(import.meta.dirname, "..", "..");
5
+ const typed = defineConfig([
6
+ tseslintConfigs.recommendedTypeChecked,
7
+ tseslintConfigs.stylisticTypeChecked,
8
+ {
9
+ files: ["**/*.{ts,tsx,mts,cts}"],
10
+ languageOptions: {
11
+ parserOptions: {
12
+ projectService: true,
13
+ tsconfigRootDir,
14
+ },
15
+ },
16
+ rules: {
17
+ "@typescript-eslint/consistent-type-imports": [
18
+ "error",
19
+ {
20
+ prefer: "type-imports",
21
+ fixStyle: "separate-type-imports",
22
+ },
23
+ ],
24
+ "@typescript-eslint/no-floating-promises": "error",
25
+ },
26
+ },
27
+ {
28
+ files: ["**/*.{js,jsx,mjs,cjs}"],
29
+ extends: [tseslintConfigs.disableTypeChecked],
30
+ },
31
+ ]);
32
+ export default typed;
33
+ //# sourceMappingURL=typed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed.js","sourceRoot":"","sources":["../../src/eslint/typed.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEtE,MAAM,KAAK,GAAG,YAAY,CAAC;IACzB,eAAe,CAAC,sBAAsB;IACtC,eAAe,CAAC,oBAAoB;IACpC;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,cAAc,EAAE,IAAI;gBACpB,eAAe;aAChB;SACF;QACD,KAAK,EAAE;YACL,4CAA4C,EAAE;gBAC5C,OAAO;gBACP;oBACE,MAAM,EAAE,cAAc;oBACtB,QAAQ,EAAE,uBAAuB;iBAClC;aACF;YACD,yCAAyC,EAAE,OAAO;SACnD;KACF;IACD;QACE,KAAK,EAAE,CAAC,uBAAuB,CAAC;QAChC,OAAO,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC;KAC9C;CACF,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@chencan-cnc/dev-config",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Shared ESLint flat configs and tsconfig bases for TypeScript projects",
7
+ "main": "./dist/eslint/index.js",
8
+ "types": "./dist/eslint/index.d.ts",
9
+ "tsconfig": "./tsconfig/base.json",
10
+ "files": [
11
+ "dist",
12
+ "tsconfig",
13
+ "README.md"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/eslint/index.d.ts",
18
+ "default": "./dist/eslint/index.js"
19
+ },
20
+ "./eslint": {
21
+ "types": "./dist/eslint/index.d.ts",
22
+ "default": "./dist/eslint/index.js"
23
+ },
24
+ "./eslint/base": {
25
+ "types": "./dist/eslint/base.d.ts",
26
+ "default": "./dist/eslint/base.js"
27
+ },
28
+ "./eslint/typed": {
29
+ "types": "./dist/eslint/typed.d.ts",
30
+ "default": "./dist/eslint/typed.js"
31
+ },
32
+ "./eslint/next": {
33
+ "types": "./dist/eslint/next.d.ts",
34
+ "default": "./dist/eslint/next.js"
35
+ },
36
+ "./eslint/tailwind": {
37
+ "types": "./dist/eslint/tailwind.d.ts",
38
+ "default": "./dist/eslint/tailwind.js"
39
+ },
40
+ "./tsconfig/base": "./tsconfig/base.json",
41
+ "./tsconfig/node-lib": "./tsconfig/node-lib.json",
42
+ "./tsconfig/next-app": "./tsconfig/next-app.json"
43
+ },
44
+ "peerDependencies": {
45
+ "eslint": "^9.39.4",
46
+ "typescript": "^5.9.3"
47
+ },
48
+ "devDependencies": {
49
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
50
+ "@eslint-react/eslint-plugin": "^1.53.1",
51
+ "@eslint/js": "^9.39.4",
52
+ "@eslint/json": "^1.2.0",
53
+ "@types/eslint-plugin-security": "^3.0.1",
54
+ "@types/node": "^20.14.8",
55
+ "eslint-config-next": "16.2.1",
56
+ "eslint-config-prettier": "^10.1.8",
57
+ "eslint-plugin-better-tailwindcss": "^4.3.2",
58
+ "eslint-plugin-import-x": "^4.16.2",
59
+ "eslint-plugin-prettier": "^5.5.5",
60
+ "eslint-plugin-react-compiler": "19.1.0-rc.2",
61
+ "eslint-plugin-regexp": "^2.10.0",
62
+ "eslint-plugin-security": "^3.0.1",
63
+ "jiti": "^2.6.1",
64
+ "prettier": "^3.8.1",
65
+ "typescript": "^5.9.3",
66
+ "typescript-eslint": "^8.58.0"
67
+ },
68
+ "scripts": {
69
+ "build": "tsc -p tsconfig.build.json",
70
+ "lint": "eslint .",
71
+ "lint:fix": "eslint . --fix",
72
+ "typecheck": "tsc -p tsconfig.json --noEmit"
73
+ }
74
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2022",
5
+ "lib": ["ES2022"],
6
+ "module": "ESNext",
7
+ "moduleResolution": "Bundler",
8
+ "strict": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "useUnknownInCatchVariables": true,
12
+ "verbatimModuleSyntax": true,
13
+ "isolatedModules": true,
14
+ "resolveJsonModule": true,
15
+ "esModuleInterop": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "noEmit": true
19
+ }
20
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
6
+ "module": "ESNext",
7
+ "moduleResolution": "Bundler",
8
+ "jsx": "preserve",
9
+ "incremental": true,
10
+ "plugins": [{ "name": "next" }]
11
+ }
12
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "lib": ["ES2022"],
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "noEmit": false
12
+ }
13
+ }