@hardlydifficult/ts-config 0.0.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,64 @@
1
+ # @hardlydifficult/ts-config
2
+
3
+ Opinionated ESLint, Prettier, and TypeScript configurations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -D @hardlydifficult/ts-config
9
+ ```
10
+
11
+ Peer dependencies for ESLint:
12
+
13
+ ```bash
14
+ npm install -D @eslint/js eslint eslint-config-prettier eslint-plugin-import typescript-eslint
15
+ ```
16
+
17
+ ## ESLint
18
+
19
+ Create `eslint.config.js`:
20
+
21
+ ```js
22
+ import createConfig from "@hardlydifficult/ts-config/eslint";
23
+ export default createConfig(import.meta.dirname);
24
+ ```
25
+
26
+ `createConfig` takes the project root directory (used for TypeScript type-checked linting).
27
+
28
+ ### Rules Included
29
+
30
+ - Strict TypeScript type checking
31
+ - Import ordering and validation
32
+ - Prettier integration (formatting errors become lint errors)
33
+ - 400-line file limit
34
+ - `no-console` (prevents accidental console statements)
35
+
36
+ ## Prettier
37
+
38
+ Add the `prettier` key to `package.json` to use the shared config:
39
+
40
+ ```json
41
+ {
42
+ "prettier": "@hardlydifficult/ts-config/prettier"
43
+ }
44
+ ```
45
+
46
+ This tells Prettier to load its config from this package. No `.prettierrc` file needed.
47
+
48
+ ## TypeScript
49
+
50
+ Base config targeting ES2022 with CommonJS modules, strict mode, and declaration output.
51
+
52
+ Create or update `tsconfig.json`:
53
+
54
+ ```json
55
+ {
56
+ "extends": "@hardlydifficult/ts-config/tsconfig.base.json",
57
+ "compilerOptions": {
58
+ "outDir": "./dist",
59
+ "rootDir": "./src"
60
+ }
61
+ }
62
+ ```
63
+
64
+ The `extends` field pulls in all shared compiler options. Add per-project overrides alongside it.
@@ -0,0 +1,2 @@
1
+ export default function createConfig(projectRoot: string): import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
2
+ //# sourceMappingURL=eslint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,WAAW,EAAE,MAAM,uEAiKvD"}
package/dist/eslint.js ADDED
@@ -0,0 +1,154 @@
1
+ import eslint from "@eslint/js";
2
+ import eslintConfigPrettier from "eslint-config-prettier";
3
+ import importPlugin from "eslint-plugin-import";
4
+ import tseslint from "typescript-eslint";
5
+ export default function createConfig(projectRoot) {
6
+ return tseslint.config({
7
+ ignores: [
8
+ "**/dist/**",
9
+ "**/node_modules/**",
10
+ "**/*.js",
11
+ "**/tests/**",
12
+ "**/vitest.config.ts",
13
+ ],
14
+ }, eslint.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked, eslintConfigPrettier, {
15
+ plugins: {
16
+ import: importPlugin,
17
+ },
18
+ }, {
19
+ languageOptions: {
20
+ parserOptions: {
21
+ projectService: true,
22
+ tsconfigRootDir: projectRoot,
23
+ },
24
+ },
25
+ }, {
26
+ rules: {
27
+ // File size limit
28
+ "max-lines": [
29
+ "error",
30
+ {
31
+ max: 400,
32
+ skipBlankLines: true,
33
+ skipComments: true,
34
+ },
35
+ ],
36
+ // Auto-fixable rules
37
+ curly: ["error", "all"],
38
+ "dot-notation": "error",
39
+ eqeqeq: ["error", "always"],
40
+ "no-else-return": ["error", { allowElseIf: false }],
41
+ "no-extra-boolean-cast": "error",
42
+ "no-lonely-if": "error",
43
+ "no-object-constructor": "error",
44
+ "no-useless-computed-key": "error",
45
+ "no-useless-rename": "error",
46
+ "no-useless-return": "error",
47
+ "no-var": "error",
48
+ "object-shorthand": ["error", "always"],
49
+ "prefer-arrow-callback": "error",
50
+ "prefer-const": "error",
51
+ "prefer-destructuring": [
52
+ "error",
53
+ {
54
+ array: false,
55
+ object: true,
56
+ },
57
+ ],
58
+ "prefer-numeric-literals": "error",
59
+ "prefer-rest-params": "error",
60
+ "prefer-spread": "error",
61
+ "prefer-template": "error",
62
+ "quote-props": ["error", "as-needed"],
63
+ "sort-imports": [
64
+ "error",
65
+ {
66
+ ignoreCase: true,
67
+ ignoreDeclarationSort: true,
68
+ ignoreMemberSort: false,
69
+ },
70
+ ],
71
+ yoda: "error",
72
+ // Non-auto-fixable rules
73
+ "array-callback-return": ["error", { allowImplicit: true }],
74
+ "default-case": "error",
75
+ "default-case-last": "error",
76
+ "default-param-last": "error",
77
+ "no-duplicate-imports": "error",
78
+ "no-empty-function": ["error", { allow: ["arrowFunctions"] }],
79
+ "no-nested-ternary": "error",
80
+ "no-invalid-this": "error",
81
+ "no-loop-func": "error",
82
+ "no-restricted-globals": [
83
+ "error",
84
+ {
85
+ name: "event",
86
+ message: "Use local event parameter instead.",
87
+ },
88
+ ],
89
+ "no-promise-executor-return": "error",
90
+ "no-self-compare": "error",
91
+ "no-template-curly-in-string": "error",
92
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
93
+ "no-unused-expressions": [
94
+ "error",
95
+ {
96
+ allowShortCircuit: true,
97
+ allowTernary: true,
98
+ },
99
+ ],
100
+ "no-useless-concat": "error",
101
+ "no-use-before-define": ["error", { functions: false, classes: false }],
102
+ "require-atomic-updates": "error",
103
+ "no-console": ["error", { allow: ["error", "warn"] }],
104
+ // Import rules
105
+ "import/extensions": "off",
106
+ "import/no-unresolved": "off",
107
+ "import/export": "error",
108
+ "import/no-absolute-path": "error",
109
+ "import/no-self-import": "error",
110
+ "import/no-cycle": ["error", { maxDepth: 10 }],
111
+ "import/no-useless-path-segments": ["error", { noUselessIndex: true }],
112
+ "import/order": [
113
+ "error",
114
+ {
115
+ groups: [
116
+ "builtin",
117
+ "external",
118
+ "internal",
119
+ "parent",
120
+ "sibling",
121
+ "index",
122
+ ],
123
+ "newlines-between": "always",
124
+ alphabetize: {
125
+ order: "asc",
126
+ caseInsensitive: true,
127
+ },
128
+ },
129
+ ],
130
+ // TypeScript rules
131
+ "@typescript-eslint/no-unused-vars": [
132
+ "error",
133
+ {
134
+ argsIgnorePattern: "^_",
135
+ varsIgnorePattern: "^_",
136
+ },
137
+ ],
138
+ "@typescript-eslint/consistent-type-imports": [
139
+ "error",
140
+ { prefer: "type-imports", fixStyle: "inline-type-imports" },
141
+ ],
142
+ "@typescript-eslint/no-explicit-any": "warn",
143
+ "@typescript-eslint/explicit-function-return-type": "off",
144
+ "@typescript-eslint/no-non-null-assertion": "warn",
145
+ "@typescript-eslint/strict-boolean-expressions": "error",
146
+ "@typescript-eslint/no-floating-promises": "error",
147
+ "@typescript-eslint/await-thenable": "error",
148
+ "@typescript-eslint/no-misused-promises": "error",
149
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
150
+ "@typescript-eslint/prefer-optional-chain": "error",
151
+ },
152
+ });
153
+ }
154
+ //# sourceMappingURL=eslint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,YAAY,CAAC;AAChC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,WAAmB;IACtD,OAAO,QAAQ,CAAC,MAAM,CACpB;QACE,OAAO,EAAE;YACP,YAAY;YACZ,oBAAoB;YACpB,SAAS;YACT,aAAa;YACb,qBAAqB;SACtB;KACF,EACD,MAAM,CAAC,OAAO,CAAC,WAAW,EAC1B,GAAG,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EACrC,GAAG,QAAQ,CAAC,OAAO,CAAC,oBAAoB,EACxC,oBAAoB,EACpB;QACE,OAAO,EAAE;YACP,MAAM,EAAE,YAAY;SACrB;KACF,EACD;QACE,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,cAAc,EAAE,IAAI;gBACpB,eAAe,EAAE,W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AAS;wBACT,OAAO;qBACR;oBACD,kBAAkB,EAAE,QAAQ;oBAC5B,WAAW,EAAE;wBACX,KAAK,EAAE,KAAK;wBACZ,eAAe,EAAE,IAAI;qBACtB;iBACF;aACF;YAED,mBAAmB;YACnB,mCAAmC,EAAE;gBACnC,OAAO;gBACP;oBACE,iBAAiB,EAAE,IAAI;oBACvB,iBAAiB,EAAE,IAAI;iBACxB;aACF;YACD,4CAA4C,EAAE;gBAC5C,OAAO;gBACP,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,qBAAqB,EAAE;aAC5D;YACD,oCAAoC,EAAE,MAAM;YAC5C,kDAAkD,EAAE,KAAK;YACzD,0CAA0C,EAAE,MAAM;YAClD,+CAA+C,EAAE,OAAO;YACxD,yCAAyC,EAAE,OAAO;YAClD,mCAAmC,EAAE,OAAO;YAC5C,wCAAwC,EAAE,OAAO;YACjD,8CAA8C,EAAE,OAAO;YACvD,0CAA0C,EAAE,OAAO;SACpD;KACF,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type Config } from "prettier";
2
+ declare const config: Config;
3
+ export default config;
4
+ //# sourceMappingURL=prettier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../src/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,QAAA,MAAM,MAAM,EAAE,MAiBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,20 @@
1
+ const config = {
2
+ semi: true,
3
+ singleQuote: false,
4
+ tabWidth: 2,
5
+ useTabs: false,
6
+ trailingComma: "es5",
7
+ bracketSpacing: true,
8
+ bracketSameLine: false,
9
+ arrowParens: "always",
10
+ endOfLine: "lf",
11
+ printWidth: 80,
12
+ quoteProps: "as-needed",
13
+ jsxSingleQuote: false,
14
+ proseWrap: "preserve",
15
+ htmlWhitespaceSensitivity: "css",
16
+ embeddedLanguageFormatting: "auto",
17
+ singleAttributePerLine: false,
18
+ };
19
+ export default config;
20
+ //# sourceMappingURL=prettier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettier.js","sourceRoot":"","sources":["../src/prettier.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAW;IACrB,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,KAAK;IAClB,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,IAAI;IACpB,eAAe,EAAE,KAAK;IACtB,WAAW,EAAE,QAAQ;IACrB,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,WAAW;IACvB,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,UAAU;IACrB,yBAAyB,EAAE,KAAK;IAChC,0BAA0B,EAAE,MAAM;IAClC,sBAAsB,EAAE,KAAK;CAC9B,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@hardlydifficult/ts-config",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ "./eslint": "./dist/eslint.js",
7
+ "./prettier": "./dist/prettier.js",
8
+ "./tsconfig.base.json": "./tsconfig.base.json"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "tsconfig.base.json"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "clean": "rm -rf dist",
17
+ "lint": "tsc --noEmit"
18
+ },
19
+ "peerDependencies": {
20
+ "@eslint/js": ">=9.0.0",
21
+ "eslint": ">=9.0.0",
22
+ "eslint-config-prettier": ">=10.0.0",
23
+ "eslint-plugin-import": ">=2.30.0",
24
+ "typescript-eslint": ">=8.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@eslint/js": "9.28.0",
28
+ "@types/node": "20.19.31",
29
+ "eslint": "9.28.0",
30
+ "eslint-config-prettier": "10.1.8",
31
+ "eslint-plugin-import": "2.32.0",
32
+ "prettier": "3.5.3",
33
+ "typescript": "5.8.3",
34
+ "typescript-eslint": "8.33.1"
35
+ }
36
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "CommonJS",
5
+ "moduleResolution": "node",
6
+ "lib": ["ES2022"],
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+ "sourceMap": true,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true
16
+ }
17
+ }