@haltcase/style 6.2.1 → 7.0.0-canary.10

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.
Files changed (61) hide show
  1. package/eslint/configs/browser.js +27 -0
  2. package/eslint/configs/cjs.js +13 -0
  3. package/eslint/configs/internal/base.js +178 -0
  4. package/eslint/configs/internal/commonjs.js +22 -0
  5. package/eslint/{rules → configs/internal}/es2015.js +17 -16
  6. package/eslint/configs/internal/simple-import-sort.js +27 -0
  7. package/eslint/configs/internal/tsdoc.js +20 -0
  8. package/eslint/{rules → configs/internal}/unicorn.js +118 -126
  9. package/eslint/configs/next.js +50 -0
  10. package/eslint/configs/node.js +27 -0
  11. package/eslint/configs/playwright-test.js +21 -0
  12. package/eslint/configs/react.js +109 -0
  13. package/eslint/configs/typescript.js +106 -0
  14. package/eslint/constants.js +23 -28
  15. package/eslint/index.js +33 -0
  16. package/eslint/rules/best-practice.js +250 -245
  17. package/eslint/rules/imports.js +94 -0
  18. package/eslint/rules/jsx-a11y.js +11 -10
  19. package/eslint/rules/playwright-test.js +25 -26
  20. package/eslint/rules/possible-errors.js +38 -45
  21. package/eslint/rules/react-x.js +78 -0
  22. package/eslint/rules/react.js +20 -113
  23. package/eslint/rules/stylistic-jsx.js +17 -0
  24. package/eslint/rules/stylistic.js +83 -84
  25. package/eslint/rules/typescript/extension.js +68 -39
  26. package/eslint/rules/typescript/import.js +16 -15
  27. package/eslint/rules/typescript/index.js +110 -121
  28. package/eslint/rules/typescript/naming-convention.js +121 -0
  29. package/eslint/rules/variables.js +34 -34
  30. package/eslint/withFiles.js +15 -0
  31. package/package.json +53 -59
  32. package/prettier/index.js +4 -11
  33. package/readme.md +183 -98
  34. package/stylelint/_base.js +2 -4
  35. package/stylelint/index.js +6 -7
  36. package/stylelint/modules.js +7 -8
  37. package/stylelint/standard.js +2 -5
  38. package/typescript/tsconfig.base.json +2 -1
  39. package/typescript/tsconfig.bundler.json +7 -3
  40. package/typescript/tsconfig.next.json +14 -6
  41. package/typescript/tsconfig.node.json +1 -1
  42. package/typescript/tsconfig.node18.json +4 -7
  43. package/typescript/tsconfig.node20.json +4 -7
  44. package/typescript/tsconfig.node22.json +10 -0
  45. package/typescript/tsconfig.web.json +1 -1
  46. package/eslint/_base.js +0 -82
  47. package/eslint/astro.js +0 -40
  48. package/eslint/browser.js +0 -8
  49. package/eslint/cjs.js +0 -12
  50. package/eslint/jest.js +0 -28
  51. package/eslint/next.js +0 -38
  52. package/eslint/node.js +0 -8
  53. package/eslint/playwright-test.js +0 -8
  54. package/eslint/react.js +0 -18
  55. package/eslint/rules/import.js +0 -92
  56. package/eslint/rules/jest.js +0 -28
  57. package/eslint/rules/simple-import-sort.js +0 -23
  58. package/eslint/rules/tsdoc.js +0 -17
  59. package/eslint/rules/typescript/strict.js +0 -18
  60. package/eslint/typescript.js +0 -26
  61. package/eslint/utils/require-package.js +0 -44
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haltcase/style",
3
- "version": "6.2.1",
3
+ "version": "7.0.0-canary.10",
4
4
  "description": "haltcase's web ecosystem style guide & configurations",
5
5
  "keywords": [
6
6
  "eslint",
@@ -17,18 +17,11 @@
17
17
  },
18
18
  "license": "MPL-2.0",
19
19
  "author": "Bo Lingen <bo@haltcase.dev> (https://haltcase.dev)",
20
+ "type": "module",
20
21
  "exports": {
22
+ "./eslint": "./eslint/index.js",
21
23
  "./eslint/rules/*": "./eslint/rules/*.js",
22
24
  "./eslint/rules/*.js": "./eslint/rules/*.js",
23
- "./eslint/astro": "./eslint/astro.js",
24
- "./eslint/browser": "./eslint/browser.js",
25
- "./eslint/cjs": "./eslint/cjs.js",
26
- "./eslint/jest": "./eslint/jest.js",
27
- "./eslint/next": "./eslint/next.js",
28
- "./eslint/node": "./eslint/node.js",
29
- "./eslint/playwright-test": "./eslint/playwright-test.js",
30
- "./eslint/react": "./eslint/react.js",
31
- "./eslint/typescript": "./eslint/typescript.js",
32
25
  "./prettier": "./prettier/index.js",
33
26
  "./stylelint": "./stylelint/index.js",
34
27
  "./stylelint/modules": "./stylelint/modules.js",
@@ -39,6 +32,7 @@
39
32
  "./typescript/node": "./typescript/tsconfig.node.json",
40
33
  "./typescript/node18": "./typescript/tsconfig.node18.json",
41
34
  "./typescript/node20": "./typescript/tsconfig.node20.json",
35
+ "./typescript/node22": "./typescript/tsconfig.node22.json",
42
36
  "./typescript/web": "./typescript/tsconfig.web.json"
43
37
  },
44
38
  "files": [
@@ -46,13 +40,12 @@
46
40
  "prettier",
47
41
  "stylelint",
48
42
  "typescript",
49
- "astro",
50
43
  "next"
51
44
  ],
52
45
  "scripts": {
53
46
  "eslint-check": "eslint --max-warnings=0 .",
54
47
  "format": "eslint --fix . && prettier --write .",
55
- "prepare": "husky install",
48
+ "prepare": "husky",
56
49
  "prettier-check": "prettier --check .",
57
50
  "semantic-release": "semantic-release",
58
51
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -60,72 +53,73 @@
60
53
  "lint-staged": {
61
54
  "*.{js,jsx,ts,tsx,css,yml,yaml}": "pnpm prettier --write"
62
55
  },
63
- "prettier": "./prettier",
56
+ "prettier": "./prettier/index.js",
64
57
  "stylelint": {
65
58
  "extends": "./stylelint/index.js"
66
59
  },
67
60
  "dependencies": {
68
- "@babel/core": "^7.23.2",
69
- "@babel/eslint-parser": "^7.22.15",
70
- "@rushstack/eslint-patch": "^1.5.1",
71
- "@typescript-eslint/eslint-plugin": "^6.9.0",
72
- "@typescript-eslint/parser": "^6.9.0",
73
- "eslint-config-prettier": "^9.0.0",
61
+ "@babel/core": "^7.26.0",
62
+ "@babel/eslint-parser": "^7.25.9",
63
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
64
+ "@eslint-react/eslint-plugin": "^1.17.1",
65
+ "@next/eslint-plugin-next": "^15.0.3",
66
+ "@stylistic/eslint-plugin-jsx": "^2.11.0",
67
+ "eslint-config-prettier": "^9.1.0",
74
68
  "eslint-import-resolver-alias": "^1.1.2",
75
- "eslint-import-resolver-typescript": "^3.6.1",
76
- "eslint-plugin-eslint-comments": "^3.2.0",
77
- "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.0",
78
- "eslint-plugin-jest": "^27.6.0",
79
- "eslint-plugin-jsx-a11y": "^6.7.1",
80
- "eslint-plugin-playwright": "^0.18.0",
81
- "eslint-plugin-react": "^7.33.2",
82
- "eslint-plugin-react-hooks": "^4.6.0",
83
- "eslint-plugin-simple-import-sort": "^10.0.0",
84
- "eslint-plugin-testing-library": "^6.1.0",
85
- "eslint-plugin-tsdoc": "^0.2.17",
86
- "eslint-plugin-unicorn": "^48.0.1",
87
- "postcss-html": "^1.6.0",
88
- "prettier-plugin-astro": "^0.12.1",
89
- "prettier-plugin-packagejson": "^2.4.6",
90
- "stylelint-config-clean-order": "^5.4.1",
69
+ "eslint-import-resolver-typescript": "^3.6.3",
70
+ "eslint-plugin-import-x": "^4.4.3",
71
+ "eslint-plugin-jsx-a11y": "^6.10.2",
72
+ "eslint-plugin-playwright": "^2.1.0",
73
+ "eslint-plugin-react": "^7.37.2",
74
+ "eslint-plugin-react-hooks": "^5.0.0",
75
+ "eslint-plugin-regexp": "^2.7.0",
76
+ "eslint-plugin-simple-import-sort": "^12.1.1",
77
+ "eslint-plugin-testing-library": "^6.5.0",
78
+ "eslint-plugin-tsdoc": "^0.4.0",
79
+ "eslint-plugin-unicorn": "^56.0.1",
80
+ "postcss-html": "^1.7.0",
81
+ "prettier-plugin-packagejson": "^2.5.6",
82
+ "prettier-plugin-tailwindcss": "^0.6.9",
83
+ "stylelint-config-clean-order": "^6.1.0",
91
84
  "stylelint-config-html": "^1.1.0",
92
- "stylelint-config-standard": "^36.0.0",
93
- "stylelint-define-config": "^1.2.0"
85
+ "stylelint-config-standard": "^36.0.1",
86
+ "stylelint-define-config": "^1.7.0",
87
+ "typescript-eslint": "^8.16.0"
94
88
  },
95
89
  "devDependencies": {
96
- "@actions/core": "^1.10.1",
90
+ "@actions/core": "^1.11.1",
97
91
  "@actions/exec": "^1.1.1",
98
- "@actions/github": "^5.1.1",
99
- "@commitlint/cli": "^18.2.0",
100
- "@commitlint/config-conventional": "^18.1.0",
101
- "@octokit/types": "^10.0.0",
92
+ "@actions/github": "^6.0.0",
93
+ "@commitlint/cli": "^19.6.0",
94
+ "@commitlint/config-conventional": "^19.6.0",
95
+ "@eslint/eslintrc": "^3.2.0",
96
+ "@eslint/js": "^9.15.0",
97
+ "@octokit/types": "^13.6.2",
102
98
  "@semantic-release/git": "^10.0.1",
103
- "@types/node": "20",
104
- "eslint": "^8.52.0",
105
- "husky": "^8.0.3",
106
- "lint-staged": "^15.0.2",
107
- "prettier": "^3.0.3",
108
- "semantic-release": "^22.0.5",
109
- "stylelint": "^16.3.1",
110
- "typescript": "^5.2.2"
99
+ "@types/eslint-config-prettier": "^6.11.3",
100
+ "@types/eslint__js": "^8.42.3",
101
+ "@types/node": "22",
102
+ "@typescript-eslint/types": "^8.16.0",
103
+ "eslint": "^9.15.0",
104
+ "eslint-define-config": "^2.1.0",
105
+ "globals": "^15.12.0",
106
+ "husky": "^9.1.7",
107
+ "lint-staged": "^15.2.10",
108
+ "prettier": "^3.4.1",
109
+ "semantic-release": "^24.2.0",
110
+ "stylelint": "^16.10.0",
111
+ "typescript": "^5.7.2"
111
112
  },
112
113
  "peerDependencies": {
113
- "@next/eslint-plugin-next": ">=13.3.0 <15",
114
- "eslint": ">=8.40.0 <9",
114
+ "eslint": ">=9",
115
115
  "prettier": ">=3.0.0 <4",
116
116
  "stylelint": ">=16.3.1 <17",
117
117
  "typescript": ">=5.0.0 <6"
118
118
  },
119
119
  "peerDependenciesMeta": {
120
- "@next/eslint-plugin-next": {
121
- "optional": true
122
- },
123
120
  "eslint": {
124
121
  "optional": true
125
122
  },
126
- "eslint-plugin-astro": {
127
- "optional": true
128
- },
129
123
  "prettier": {
130
124
  "optional": true
131
125
  },
@@ -136,7 +130,7 @@
136
130
  "optional": true
137
131
  }
138
132
  },
139
- "packageManager": "pnpm@8.6.1",
133
+ "packageManager": "pnpm@9.10.0+sha256.355a8ab8dbb6ad41befbef39bc4fd6b5df85e12761d2724bd01f13e878de4b13",
140
134
  "engines": {
141
135
  "node": ">=20"
142
136
  },
package/prettier/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ /* eslint-disable import-x/no-default-export */
2
2
 
3
3
  /**
4
4
  * Some of Prettier's defaults can be overridden by an EditorConfig file. We
@@ -13,17 +13,10 @@ const overridableDefaults = {
13
13
  useTabs: true
14
14
  };
15
15
 
16
- module.exports = {
16
+ export default {
17
17
  ...overridableDefaults,
18
18
  singleQuote: false,
19
19
  trailingComma: "none",
20
- plugins: ["prettier-plugin-astro", "prettier-plugin-packagejson"],
21
- overrides: [
22
- {
23
- files: "*.astro",
24
- options: {
25
- parser: "astro"
26
- }
27
- }
28
- ]
20
+ plugins: ["prettier-plugin-packagejson", "prettier-plugin-tailwindcss"],
21
+ tailwindAttributes: ["classNames", "clsx", "cx", "twMerge"]
29
22
  };
package/readme.md CHANGED
@@ -7,26 +7,27 @@
7
7
  - [TypeScript](#typescript)
8
8
  - [Stylelint](#stylelint)
9
9
 
10
- > This package originated from [Vercel's style guide](https://github.com/vercel/style-guide).
10
+ > This package originated from [Vercel's style guide](https://github.com/vercel/style-guide),
11
+ > but has since diverged in both architecture and rules.
11
12
 
12
13
  ## installation
13
14
 
14
15
  Install `@haltcase/style` with your preferred package manager:
15
16
 
16
17
  ```sh
18
+ # pnpm
19
+ pnpm add --save-dev @haltcase/style
20
+
17
21
  # npm
18
22
  npm i --save-dev @haltcase/style
19
23
 
20
- # pnpm
21
- pnpm i --save-dev @haltcase/style
22
-
23
24
  # yarn
24
25
  yarn add --dev @haltcase/style
25
26
  ```
26
27
 
27
28
  > [!NOTE]
28
29
  > Some scenarios require additional peer dependencies.
29
- > See the [Prettier](#prettier) and [ESLint](#eslint) sections.
30
+ > See the [Prettier](#prettier), [ESLint](#eslint), and [Stylelint](#stylelint) sections.
30
31
 
31
32
  ## usage
32
33
 
@@ -54,73 +55,158 @@ Add the following in `package.json`:
54
55
  >
55
56
  > See: https://eslint.org/docs/user-guide/getting-started#installation-and-usage
56
57
 
57
- Several ESLint configs are available which can be combined.
58
+ > [!IMPORTANT]
59
+ > This config requires ESLint 9+ and the use of
60
+ > [flat config](https://eslint.org/docs/latest/extend/plugin-migration-flat-config).
58
61
 
59
- Start with at least one of these base configs, which should always be first in `extends`:
62
+ At its simplest, your config might look like this for a general purpose
63
+ project:
60
64
 
61
- - `@haltcase/style/eslint/browser`
62
- - `@haltcase/style/eslint/node`
65
+ ```js
66
+ // eslint.config.js
67
+ import { getEslintConfig } from "@haltcase/style/eslint";
63
68
 
64
- > [!TIP]
65
- > You can scope configs so they only target specific files.
66
- >
67
- > See: [Scoped configuration with `overrides`](#scoped-configuration-with-overrides).
69
+ export default getEslintConfig();
70
+ ```
71
+
72
+ TypeScript support is enabled by default by applying TypeScript-specific
73
+ configurations to files with TypeScript file extensions
74
+ (`ts`, `tsx`, `mts`, and `mtsx`). You may need to apply your own project-specific
75
+ configurations &mdash; see [Configuring ESLint for TypeScript](#configuring-eslint-for-typescript)
76
+ for details on how to do so.
77
+
78
+ #### ESLint customization
79
+
80
+ You can enable more rules for your project with configuration options:
81
+
82
+ ```js
83
+ // eslint.config.js
84
+ import { getEslintConfig } from "@haltcase/style/eslint";
68
85
 
69
- The following additional configs are available:
86
+ export default getEslintConfig({
87
+ // for browser environments
88
+ browser: true,
70
89
 
71
- - `@haltcase/style/eslint/astro` (requires `eslint-plugin-astro` to be installed)
72
- - `@haltcase/style/eslint/cjs`
73
- - `@haltcase/style/eslint/jest`
74
- - `@haltcase/style/eslint/next` (requires `@next/eslint-plugin-next` to be installed at the same version as `next`)
75
- - `@haltcase/style/eslint/playwright-test`
76
- - `@haltcase/style/eslint/react`
77
- - `@haltcase/style/eslint/typescript` (requires `typescript` to be installed and [additional configuration](#configuring-eslint-for-typescript))
90
+ // treat *.js files as CommonJS instead of ES Modules
91
+ commonjs: true,
78
92
 
79
- Be sure to use `require.resolve` to reference these configs &mdash; ESLint requires absolute paths ([eslint/eslint#9188](https://github.com/eslint/eslint/issues/9188)).
93
+ // for Next.js projects (implies `react`)
94
+ nextjs: true,
80
95
 
81
- For example, to use the shared ESLint config(s) in a Next.js project, set the
82
- following in `.eslintrc.js`.
96
+ // for Node.js projects
97
+ node: true,
98
+
99
+ // for React
100
+ react: true
101
+ });
102
+ ```
103
+
104
+ And, of course, you may include configs as any part of a larger one:
83
105
 
84
106
  ```js
85
- module.exports = {
86
- extends: [
87
- require.resolve("@haltcase/style/eslint/browser"),
88
- require.resolve("@haltcase/style/eslint/react"),
89
- require.resolve("@haltcase/style/eslint/next")
90
- ]
91
- };
107
+ // eslint.config.js
108
+ import { getEslintConfig } from "@haltcase/style/eslint";
109
+
110
+ export default [
111
+ ...getEslintConfig({
112
+ nextjs: true
113
+ }),
114
+
115
+ {
116
+ name: "Customizations",
117
+ files: ["src/lib/**"],
118
+ rules: {
119
+ "no-unused-vars": "warn"
120
+ }
121
+ }
122
+ ];
92
123
  ```
93
124
 
125
+ You can be more granular with your customizations by using the modular configs
126
+ also exported from `@haltcase/style/eslint`:
127
+
128
+ ```js
129
+ // eslint.config.js
130
+ import {
131
+ getEslintBaseConfig,
132
+ getEslintBrowserConfig,
133
+ getEslintNodeConfig,
134
+ getEslintReactConfig,
135
+ withFiles
136
+ } from "@haltcase/style/eslint";
137
+
138
+ export default [
139
+ // use the base config for everything by default
140
+ ...getEslintBaseConfig(),
141
+
142
+ // apply browser rules to some files
143
+ ...getEslintBrowserConfig().map((config) => ({
144
+ ...config,
145
+ files: ["src/client-only/**/*.js"]
146
+ })),
147
+
148
+ // apply React rules to some files
149
+ // (`withFiles` is equivalent to the above `map`)
150
+ ...withFiles(getEslintReactConfig(), ["src/frontend/**/*.{ts,js,tsx,jsx}"]),
151
+
152
+ ...withFiles(getEslintNodeConfig(), ["src/backend/**/*.{ts,js}"]),
153
+
154
+ {
155
+ name: "Customizations",
156
+ files: ["src/lib/**"],
157
+ rules: {
158
+ "no-unused-vars": "warn"
159
+ }
160
+ }
161
+ ];
162
+ ```
163
+
164
+ > [!TIP]
165
+ > See the ESLint documentation for more details on using configs:
166
+ > https://eslint.org/docs/latest/use/configure/combine-configs
167
+
94
168
  #### Configuring ESLint for TypeScript
95
169
 
96
170
  Some of the rules enabled in the TypeScript config require additional type
97
- information, so you'll need to use `project: true` and `tsconfigRootDir` or
98
- explicitly supply the path(s) to your `tsconfig.json` per the typescript-eslint
99
- documentation.
171
+ information. By default, this config will configure `parserOptions` with
172
+ [`project: true`](https://typescript-eslint.io/packages/parser/#project).
100
173
 
101
- For more information, see: https://typescript-eslint.io/linting/typed-linting/
174
+ You can customize this behavior with the `typescriptProject` option:
102
175
 
103
176
  ```js
104
- module.exports = {
105
- root: true,
106
- extends: [
107
- require.resolve("@haltcase/style/eslint/node"),
108
- require.resolve("@haltcase/style/eslint/typescript")
109
- ],
110
- parserOptions: {
111
- project: true,
112
- tsconfigRootDir: __dirname
113
- },
114
- settings: {
115
- "import/resolver": {
116
- typescript: {
117
- project
118
- }
177
+ import { getEslintConfig } from "@haltcase/style/eslint";
178
+
179
+ export default [
180
+ ...getEslintConfig({
181
+ typescriptProject: [
182
+ "./packages/**/tsconfig.json",
183
+ "./separate-package/tsconfig.json"
184
+ ]
185
+ })
186
+ ];
187
+ ```
188
+
189
+ If you need to further customize the TypeScript behavior, use a separate config
190
+ with your own options, for example:
191
+
192
+ ```js
193
+ import { getEslintConfig } from "@haltcase/style/eslint";
194
+
195
+ export default [
196
+ ...getEslintConfig(),
197
+
198
+ {
199
+ files: ["*.{c,m,}ts{x,}"],
200
+ parserOptions: {
201
+ project: true,
202
+ tsConfigRootDir: "/custom/config/directory"
119
203
  }
120
204
  }
121
- };
205
+ ];
122
206
  ```
123
207
 
208
+ For more information, see: https://typescript-eslint.io/linting/typed-linting/
209
+
124
210
  #### Configuring custom components for `jsx-a11y`
125
211
 
126
212
  It's common practice for React apps to have shared components like `Button`
@@ -130,63 +216,51 @@ via the `components` setting.
130
216
  The below list is not exhaustive.
131
217
 
132
218
  ```js
133
- module.exports = {
134
- root: true,
135
- extends: [require.resolve("@haltcase/style/eslint/react")],
136
- settings: {
137
- "jsx-a11y": {
138
- components: {
139
- Article: "article",
140
- Button: "button",
141
- Image: "img",
142
- Input: "input",
143
- Link: "a",
144
- Video: "video"
219
+ import { getEslintConfig } from "@haltcase/style/eslint";
220
+
221
+ export default [
222
+ getEslintConfig({
223
+ react: true
224
+ }),
225
+
226
+ {
227
+ settings: {
228
+ "jsx-a11y": {
229
+ components: {
230
+ Article: "article",
231
+ Button: "button",
232
+ Image: "img",
233
+ Input: "input",
234
+ Link: "a",
235
+ Video: "video"
236
+ }
145
237
  }
146
238
  }
147
239
  }
148
- };
149
- ```
150
-
151
- #### Scoped configuration with `overrides`
152
-
153
- ESLint configs can be scoped to include/exclude specific paths. This ensures
154
- that rules don't "leak" into places where those rules don't apply.
155
-
156
- In this example, Jest rules are only being applied to files matching Jest's
157
- default test match pattern.
158
-
159
- ```js
160
- module.exports = {
161
- extends: [require.resolve("@haltcase/style/eslint/node")],
162
- overrides: [
163
- {
164
- files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
165
- extends: [require.resolve("@haltcase/style/eslint/jest")]
166
- }
167
- ]
168
- };
240
+ ];
169
241
  ```
170
242
 
171
243
  ##### A note on file extensions
172
244
 
173
- By default, all TypeScript rules are scoped to files ending with `.ts` and
174
- `.tsx`.
245
+ By default, all TypeScript rules are scoped to files with extensions ending in
246
+ `ts` or `tsx`.
175
247
 
176
- However, when using overrides, file extensions must be included or ESLint will
177
- only include `.js` files.
248
+ If you need to override configuration for TypeScript files, make sure to
249
+ specify the `files` property or ESLint will
250
+ [only target `*.js` files](https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores).
178
251
 
179
252
  ```js
180
- module.exports = {
181
- overrides: [
182
- {
183
- files: ["directory/**/*.[jt]s?(x)"],
184
- rules: {
185
- "my-rule": "off"
186
- }
253
+ export default [
254
+ ...getEslintConfig(),
255
+
256
+ {
257
+ // apply this config to js, ts, jsx, and tsx files
258
+ files: ["directory/**/*.[jt]s?(x)"],
259
+ rules: {
260
+ "my-rule": "off"
187
261
  }
188
- ]
189
- };
262
+ }
263
+ ];
190
264
  ```
191
265
 
192
266
  ### TypeScript
@@ -198,9 +272,10 @@ Several Typescript configs are available to cover various scenarios:
198
272
  | `@haltcase/style/typescript/base` | Baseline config, intended to be extended from. |
199
273
  | `@haltcase/style/typescript/bundler` | For use in bundled projects, most commonly [Vite](https://vitejs.dev/) + [React](https://react.dev). |
200
274
  | `@haltcase/style/typescript/next` | For use in [Next.js](https://nextjs.org/) projects. |
201
- | `@haltcase/style/typescript/node` | Default Node config, currently targeting Node 20. |
275
+ | `@haltcase/style/typescript/node` | Default Node config, currently targeting Node 22. |
202
276
  | `@haltcase/style/typescript/node18` | For projects targeting Node 18. |
203
277
  | `@haltcase/style/typescript/node20` | For projects targeting Node 20. |
278
+ | `@haltcase/style/typescript/node22` | For projects targeting Node 22. |
204
279
  | `@haltcase/style/typescript/web` | For use in web projects. |
205
280
 
206
281
  Typically, you'll only need to extend from one of these:
@@ -225,6 +300,16 @@ You could also combine them with an `extends` array in [Typescript 5+](https://d
225
300
  > [!TIP]
226
301
  > Run `tsc --showConfig` to see the result of the combined configs.
227
302
 
303
+ #### TypeScript includes, excludes, and `paths` aliases
304
+
305
+ Some TypeScript configs set `include`, `exclude`, and `paths` for you with
306
+ common options. Currently:
307
+
308
+ | Name | Description |
309
+ | ------------------------------------ | --------------------------------------------------------------------------------- |
310
+ | `@haltcase/style/typescript/bundler` | Includes `@/*` → `src/*` path alias. |
311
+ | `@haltcase/style/typescript/next` | Includes `@/*` → `src/*` path alias and Next.js `include` and `exclude` settings. |
312
+
228
313
  ### Stylelint
229
314
 
230
315
  To format and check CSS with Stylelint, install the `stylelint` package and
@@ -1,10 +1,8 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { defineConfig } from "stylelint-define-config";
4
4
 
5
- const defineConfig = require("stylelint-define-config").defineConfig;
6
-
7
- module.exports = defineConfig({
5
+ export const stylelintBase = defineConfig({
8
6
  extends: [
9
7
  "stylelint-config-standard",
10
8
  "stylelint-config-html",
@@ -1,16 +1,15 @@
1
1
  // @ts-check
2
+ /* eslint-disable import-x/no-default-export */
2
3
 
3
- "use strict";
4
+ import { defineConfig } from "stylelint-define-config";
4
5
 
5
- const defineConfig = require("stylelint-define-config").defineConfig;
6
+ import { stylelintBase } from "./_base.js";
6
7
 
7
- const base = require("./_base.js");
8
-
9
- module.exports = defineConfig({
10
- ...base,
8
+ export default defineConfig({
9
+ ...stylelintBase,
11
10
 
12
11
  rules: {
13
- ...base.rules,
12
+ ...stylelintBase.rules,
14
13
 
15
14
  // disable identifier casing rules
16
15
  "custom-media-pattern": null,
@@ -1,18 +1,17 @@
1
1
  // @ts-check
2
+ /* eslint-disable import-x/no-default-export */
2
3
 
3
- "use strict";
4
+ import { defineConfig } from "stylelint-define-config";
4
5
 
5
- const defineConfig = require("stylelint-define-config").defineConfig;
6
+ import { stylelintBase } from "./_base.js";
6
7
 
7
- const base = require("./_base.js");
8
+ const camelCaseRegex = /^[a-z][a-zA-Z0-9]+$/;
8
9
 
9
- const camelCaseRegex = /^(?<=^|[^A-Z_a-z])_*[a-z]+[A-Z_a-z]*$/;
10
-
11
- module.exports = defineConfig({
12
- ...base,
10
+ export default defineConfig({
11
+ ...stylelintBase,
13
12
 
14
13
  rules: {
15
- ...base.rules,
14
+ ...stylelintBase.rules,
16
15
 
17
16
  "custom-media-pattern": camelCaseRegex,
18
17
 
@@ -1,7 +1,4 @@
1
1
  // @ts-check
2
+ /* eslint-disable import-x/no-default-export */
2
3
 
3
- "use strict";
4
-
5
- const base = require("./_base.js");
6
-
7
- module.exports = base;
4
+ export { stylelintBase as default } from "./_base.js";
@@ -8,6 +8,7 @@
8
8
  "noFallthroughCasesInSwitch": true,
9
9
  "noUncheckedIndexedAccess": true,
10
10
  "skipLibCheck": true,
11
- "strict": true
11
+ "strict": true,
12
+ "useDefineForClassFields": true
12
13
  }
13
14
  }