@whiteeclipse/toolchain 0.0.0-stage → 0.1.0-alpha.2
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/LICENCE +7 -0
- package/README.md +183 -2
- package/dist/eslint/index.d.ts +3 -0
- package/dist/eslint/index.js +41 -0
- package/dist/eslint/plugins/core.d.ts +2 -0
- package/dist/eslint/plugins/core.js +111 -0
- package/dist/eslint/plugins/import-x.d.ts +2 -0
- package/dist/eslint/plugins/import-x.js +26 -0
- package/dist/eslint/plugins/jsdoc.d.ts +2 -0
- package/dist/eslint/plugins/jsdoc.js +66 -0
- package/dist/eslint/plugins/typescript.d.ts +2 -0
- package/dist/eslint/plugins/typescript.js +67 -0
- package/dist/prettier.d.ts +4 -0
- package/dist/prettier.js +27 -0
- package/package.json +52 -5
package/LICENCE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 White Eclipse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,184 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
id: toolchain-readme
|
|
3
|
+
standard_revision: 1
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @whiteeclipse/toolchain
|
|
7
|
+
|
|
8
|
+
Shared ESLint and Prettier configurations for White Eclipse's JavaScript and TypeScript workspaces. This README covers
|
|
9
|
+
`0.1.0-alpha.1`, an exploratory alpha package.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Install the exploratory release with `bun add --dev @whiteeclipse/toolchain@0.1.0-alpha.1`; the registry tag is `alpha`.
|
|
14
|
+
The workspace instructions below apply when developing this repository.
|
|
15
|
+
|
|
16
|
+
Add the package to a consuming workspace's development dependencies, then run `bun install`:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@whiteeclipse/toolchain": "workspace:*"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Install compatible peers according to [package.json](./package.json):
|
|
27
|
+
|
|
28
|
+
| Peer | Supported versions |
|
|
29
|
+
|------------|--------------------|
|
|
30
|
+
| ESLint | `10.13.0` |
|
|
31
|
+
| Prettier | `3.9.10` |
|
|
32
|
+
| TypeScript | `6.0.3` |
|
|
33
|
+
|
|
34
|
+
Run `bun run --cwd packages/libraries/toolchain build` from the repository root before consuming the package.
|
|
35
|
+
Entrypoints select built `dist/*.js` files by default, adjacent `.d.ts` files for types, and built JavaScript when the
|
|
36
|
+
consumer enables the `development` condition. The examples run tools with Bun; the built configuration entrypoints also
|
|
37
|
+
load through Node ESM.
|
|
38
|
+
|
|
39
|
+
Create `eslint.config.ts` at the workspace root:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { defineConfig } from "eslint/config";
|
|
43
|
+
import config from "@whiteeclipse/toolchain/eslint";
|
|
44
|
+
|
|
45
|
+
export default defineConfig(config, {
|
|
46
|
+
languageOptions: {
|
|
47
|
+
parserOptions: { tsconfigRootDir: import.meta.dirname },
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For an ESM workspace, create `.prettierrc.js`:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
export { default } from "@whiteeclipse/toolchain/prettier";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Running checks
|
|
59
|
+
|
|
60
|
+
With dependencies installed, run `bun run lint` from the repository root to check all packages and applications, or from
|
|
61
|
+
an individual workspace to check only that workspace. The toolchain workspace imports its own source configuration
|
|
62
|
+
directly. Consuming workspaces may load the built entrypoint, so rebuild the toolchain after changing shared rules.
|
|
63
|
+
Passing `--conditions=development` to `bun run` does not propagate that condition to the ESLint subprocess.
|
|
64
|
+
|
|
65
|
+
To load shared rules from source, invoke ESLint directly from the repository root:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
bun --conditions=development ./node_modules/.bin/eslint .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
For consumers using the built entrypoints, run checks from the workspace root:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
bunx --bun --no-install eslint .
|
|
75
|
+
bunx --bun --no-install prettier --check .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Use ESLint's `--fix` or Prettier's `--write` to apply available fixes, then review the changes. ESLint cannot automatically fix every finding.
|
|
79
|
+
|
|
80
|
+
## Configuration behaviour
|
|
81
|
+
|
|
82
|
+
The package exposes two default exports; it has no package-root export:
|
|
83
|
+
|
|
84
|
+
- **`@whiteeclipse/toolchain/eslint`:** a flat configuration array combining JavaScript correctness, type-aware TypeScript, import boundaries, promise handling, JSDoc, readability, and JSX checks.
|
|
85
|
+
- **`@whiteeclipse/toolchain/prettier`:** a configuration object using 120-column lines, four-space indentation, double
|
|
86
|
+
quotes, semicolons, trailing commas, and LF endings. It includes `prettier-plugin-packagejson` for package-file
|
|
87
|
+
formatting and `prettier-plugin-tailwindcss` for automatic utility-class ordering. The Tailwind plugin loads last.
|
|
88
|
+
|
|
89
|
+
Typed linting uses TypeScript's project service, so checked TypeScript files need an appropriate `tsconfig.json`. Import
|
|
90
|
+
resolution supports Bun and checks `tsconfig.json` in the current directory as well as projects at
|
|
91
|
+
`apps/*/tsconfig.json` and `packages/*/*/tsconfig.json`. Repository workspace configurations set `tsconfigRootDir` to
|
|
92
|
+
their own directory, and their TypeScript projects include the ESLint configuration and relevant scripts.
|
|
93
|
+
|
|
94
|
+
JSDoc is required on interfaces, standalone functions, and class methods. PascalCase function declarations and assigned
|
|
95
|
+
functions with an explicit `ReactElement` or `React.ReactElement` return annotation may omit JSDoc; a union with `null`
|
|
96
|
+
is also supported. Inferred returns, type aliases, hooks, and other return types do not receive this exception. These
|
|
97
|
+
components may also use summary-only JSDoc without `@param` or `@returns`. Other checks, including supplied tag names
|
|
98
|
+
and parameter names, still apply. Object-literal methods and function-valued
|
|
99
|
+
properties do not require duplicate comments; document their contracts on the corresponding types. Any JSDoc supplied on
|
|
100
|
+
an implementation is still checked.
|
|
101
|
+
|
|
102
|
+
JavaScript files, configuration files, and scripts receive Node globals. Source files under `src` and Storybook files receive browser globals; overlapping patterns can receive both. Test files relax selected function-name, numeric-literal, and named-capture rules while retaining other checks.
|
|
103
|
+
|
|
104
|
+
ESLint ignores dependency directories, `dist`, `storybook-static`, `coverage`, `.idea`, and `.obsidian`. Prettier's file selection is controlled separately by the consumer's command targets and ignore file.
|
|
105
|
+
|
|
106
|
+
See
|
|
107
|
+
the [ESLint entrypoint](https://github.com/whiteeclipse-studio/hypatia/blob/feature/website/packages/libraries/toolchain/src/eslint/index.ts), [rule groups](https://github.com/whiteeclipse-studio/hypatia/tree/feature/website/packages/libraries/toolchain/src/eslint/plugins),
|
|
108
|
+
and [Prettier configuration](https://github.com/whiteeclipse-studio/hypatia/blob/feature/website/packages/libraries/toolchain/src/prettier.ts)
|
|
109
|
+
for complete settings.
|
|
110
|
+
|
|
111
|
+
## Extending configurations
|
|
112
|
+
|
|
113
|
+
Append file-specific ESLint configuration to the shared array. For example, declare the Bun global for scripts that use its APIs:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { defineConfig } from "eslint/config";
|
|
117
|
+
import config from "@whiteeclipse/toolchain/eslint";
|
|
118
|
+
|
|
119
|
+
export default defineConfig(config, {
|
|
120
|
+
files: ["scripts/**/*.ts"],
|
|
121
|
+
languageOptions: { globals: { Bun: "readonly" } },
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Spread the Prettier configuration to customize an option:
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
import config from "@whiteeclipse/toolchain/prettier";
|
|
129
|
+
|
|
130
|
+
export default { ...config, printWidth: 100 };
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Tailwind class formatting
|
|
134
|
+
|
|
135
|
+
Use the shared Prettier configuration to sort utility classes consistently. Tailwind recommends its official plugin
|
|
136
|
+
in [Automatic Class Sorting with Prettier](https://tailwindcss.com/blog/automatic-class-sorting-with-prettier). Sorting
|
|
137
|
+
groups related utilities and state variants; it does not shorten long class lists or automatically split them into
|
|
138
|
+
logical groups.
|
|
139
|
+
|
|
140
|
+
For Tailwind CSS v4, consuming workspaces must configure `tailwindStylesheet` with the CSS entrypoint, relative to their
|
|
141
|
+
Prettier configuration file:
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
import config from "@whiteeclipse/toolchain/prettier";
|
|
145
|
+
|
|
146
|
+
export default {
|
|
147
|
+
...config,
|
|
148
|
+
tailwindStylesheet: "./src/styles/index.css",
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Hypatia's root configuration supplies separate stylesheet overrides for Website and Storybook. See the
|
|
153
|
+
plugin's [stylesheet configuration](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#specifying-your-tailwind-stylesheet-path-tailwind-css-v4)
|
|
154
|
+
and [plugin-order requirement](https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins)
|
|
155
|
+
when extending this setup.
|
|
156
|
+
|
|
157
|
+
## Troubleshooting
|
|
158
|
+
|
|
159
|
+
| Symptom | Action |
|
|
160
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
161
|
+
| TypeScript or ESM configuration cannot load | Run the tools with Bun and ensure ESM `.js` configuration files belong to a `"type": "module"` package. |
|
|
162
|
+
| A plugin or peer cannot resolve | Restore workspace dependencies and check the peer ranges above. |
|
|
163
|
+
| The package root or an internal subpath cannot be imported | Use the public `/eslint` or `/prettier` entrypoint. |
|
|
164
|
+
| TypeScript project-service parsing fails | Include the file in the appropriate `tsconfig.json` and verify `tsconfigRootDir`. |
|
|
165
|
+
| Imports fail in a different workspace layout | Override the resolver's project paths and declare the resolver dependency in the consumer. |
|
|
166
|
+
| A file receives inappropriate globals or is not checked | Review the environment patterns, shared ignores, and command targets; apply a file-specific override where needed. |
|
|
167
|
+
|
|
168
|
+
## Copyright and licence
|
|
169
|
+
|
|
170
|
+
Copyright © 2026 White Eclipse.
|
|
171
|
+
|
|
172
|
+
Released under the [MIT License](https://whiteeclipse.dev/LICENCE).
|
|
173
|
+
|
|
174
|
+
## Revisions
|
|
175
|
+
|
|
176
|
+
| Revision | Date | Author | Description |
|
|
177
|
+
|----------|------------|---------------|--------------------------------------------------------------------|
|
|
178
|
+
| 1 | 2026-10-25 | Akane SHIMOKA | Adds the package README. |
|
|
179
|
+
| 2 | 2026-10-26 | Akane SHIMOKA | Consolidate documentation |
|
|
180
|
+
| 3 | 2026-10-27 | Codex | Add built JavaScript, declaration, and development exports |
|
|
181
|
+
| 4 | 2026-10-30 | Codex | Document repository and workspace lint commands |
|
|
182
|
+
| 5 | 2026-10-30 | Akane SHIMOKA | Clarify object-literal JSDoc exemptions and shared rule loading |
|
|
183
|
+
| 6 | 2026-11-04 | Akane SHIMOKA | Add Tailwind class sorting and the React component JSDoc exception |
|
|
184
|
+
| 7 | 2026-11-04 | Akane SHIMOKA | Document alpha registry installation and release packaging |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 - White Eclipse
|
|
3
|
+
* Released under the MIT Licence.
|
|
4
|
+
*/
|
|
5
|
+
import { defineConfig } from "eslint/config";
|
|
6
|
+
import globals from "globals";
|
|
7
|
+
import core from "./plugins/core.js";
|
|
8
|
+
import typescript from "./plugins/typescript.js";
|
|
9
|
+
import importX from "./plugins/import-x.js";
|
|
10
|
+
import jsdoc from "./plugins/jsdoc.js";
|
|
11
|
+
/** Shared checks for source, configuration, and scripts; generated output is excluded. */
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
ignores: [
|
|
14
|
+
"**/node_modules/**",
|
|
15
|
+
"**/dist/**",
|
|
16
|
+
"**/storybook-static/**",
|
|
17
|
+
"**/coverage/**",
|
|
18
|
+
".idea/**",
|
|
19
|
+
".obsidian/**",
|
|
20
|
+
],
|
|
21
|
+
}, core, typescript, importX, jsdoc, {
|
|
22
|
+
name: "@whiteeclipse/toolchain/eslint/runtime",
|
|
23
|
+
files: ["**/*.{js,mjs,cjs}", "**/*.config.{ts,mts,cts}", "**/scripts/**/*.{ts,mts,cts}"],
|
|
24
|
+
languageOptions: { globals: globals.node },
|
|
25
|
+
}, {
|
|
26
|
+
name: "@whiteeclipse/toolchain/eslint/browser",
|
|
27
|
+
files: ["**/src/**/*.{js,jsx,ts,tsx}", "**/.storybook/**/*.{ts,tsx}"],
|
|
28
|
+
languageOptions: { globals: globals.browser },
|
|
29
|
+
}, {
|
|
30
|
+
name: "@whiteeclipse/toolchain/eslint/jsx",
|
|
31
|
+
files: ["**/*.{jsx,tsx}"],
|
|
32
|
+
rules: {
|
|
33
|
+
"no-restricted-syntax": [
|
|
34
|
+
"error",
|
|
35
|
+
{
|
|
36
|
+
selector: "JSXExpressionContainer CallExpression[callee.type='MemberExpression'][callee.property.name='map']",
|
|
37
|
+
message: "Move array mapping above the JSX or into a component or hook (RFC-0002).",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 - White Eclipse
|
|
3
|
+
* Released under the MIT Licence.
|
|
4
|
+
*/
|
|
5
|
+
import { defineConfig } from "eslint/config";
|
|
6
|
+
import JavaScript from "@eslint/js";
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
name: "@whiteeclipse/toolchain/eslint/core",
|
|
9
|
+
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
|
|
10
|
+
extends: [JavaScript.configs.recommended],
|
|
11
|
+
rules: {
|
|
12
|
+
"array-callback-return": ["error", { checkForEach: true }],
|
|
13
|
+
"no-constructor-return": "error",
|
|
14
|
+
"no-duplicate-imports": ["error", { includeExports: true }],
|
|
15
|
+
"no-promise-executor-return": "error",
|
|
16
|
+
"no-self-compare": "error",
|
|
17
|
+
"no-template-curly-in-string": "error",
|
|
18
|
+
"no-unreachable-loop": "error",
|
|
19
|
+
"arrow-body-style": ["error", "as-needed", { requireReturnForObjectLiteral: true }],
|
|
20
|
+
complexity: ["warn", { max: 10, variant: "modified" }],
|
|
21
|
+
curly: ["error", "all"],
|
|
22
|
+
"default-case-last": "error",
|
|
23
|
+
eqeqeq: ["error", "always"],
|
|
24
|
+
"func-names": ["error", "as-needed"],
|
|
25
|
+
"max-params": ["error", { max: 4 }],
|
|
26
|
+
"max-depth": ["error", { max: 3 }],
|
|
27
|
+
"max-lines": ["error", { max: 200, skipBlankLines: true, skipComments: true }],
|
|
28
|
+
"max-lines-per-function": ["error", { max: 200, skipBlankLines: true, skipComments: true }],
|
|
29
|
+
"max-nested-callbacks": ["error", { max: 3 }],
|
|
30
|
+
"max-statements": ["error", { max: 20 }],
|
|
31
|
+
"new-cap": "error",
|
|
32
|
+
"no-alert": "error",
|
|
33
|
+
"no-array-constructor": "error",
|
|
34
|
+
"no-console": "error",
|
|
35
|
+
"no-eq-null": "error",
|
|
36
|
+
"no-eval": "error",
|
|
37
|
+
"no-implied-eval": "error",
|
|
38
|
+
"no-extend-native": "error",
|
|
39
|
+
"no-extra-bind": "error",
|
|
40
|
+
"no-extra-boolean-cast": ["error", { enforceForInnerExpressions: true }],
|
|
41
|
+
"no-implicit-coercion": ["error", { disallowTemplateShorthand: true }],
|
|
42
|
+
"no-iterator": "error",
|
|
43
|
+
"no-labels": "error",
|
|
44
|
+
"no-lone-blocks": "error",
|
|
45
|
+
"no-lonely-if": "error",
|
|
46
|
+
"no-loop-func": "error",
|
|
47
|
+
"no-magic-numbers": [
|
|
48
|
+
"error",
|
|
49
|
+
{
|
|
50
|
+
ignore: [0, 1],
|
|
51
|
+
ignoreArrayIndexes: true,
|
|
52
|
+
ignoreNumericLiteralTypes: true,
|
|
53
|
+
ignoreTypeIndexes: true,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
"no-negated-condition": "error",
|
|
57
|
+
"no-nested-ternary": "error",
|
|
58
|
+
"no-unneeded-ternary": "error",
|
|
59
|
+
"no-new": "error",
|
|
60
|
+
"no-new-func": "error",
|
|
61
|
+
"no-new-wrappers": "error",
|
|
62
|
+
"no-object-constructor": "error",
|
|
63
|
+
"no-param-reassign": ["error", { props: true }],
|
|
64
|
+
"no-proto": "error",
|
|
65
|
+
"no-script-url": "error",
|
|
66
|
+
"no-sequences": "error",
|
|
67
|
+
"no-throw-literal": "error",
|
|
68
|
+
"no-useless-call": "error",
|
|
69
|
+
"no-useless-constructor": "error",
|
|
70
|
+
"no-useless-escape": "error",
|
|
71
|
+
"no-useless-return": "error",
|
|
72
|
+
"no-unused-vars": [
|
|
73
|
+
"error",
|
|
74
|
+
{
|
|
75
|
+
args: "all",
|
|
76
|
+
argsIgnorePattern: "^_",
|
|
77
|
+
varsIgnorePattern: "^_",
|
|
78
|
+
caughtErrors: "all",
|
|
79
|
+
caughtErrorsIgnorePattern: "^_",
|
|
80
|
+
destructuredArrayIgnorePattern: "^_",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
"no-var": "error",
|
|
84
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
85
|
+
"no-warning-comments": ["error", { terms: ["FIXME"], location: "anywhere" }],
|
|
86
|
+
"object-shorthand": ["error", "always", { avoidQuotes: true, avoidExplicitReturnArrows: true }],
|
|
87
|
+
"prefer-const": ["error", { destructuring: "all" }],
|
|
88
|
+
"prefer-exponentiation-operator": "error",
|
|
89
|
+
"prefer-named-capture-group": "error",
|
|
90
|
+
"prefer-numeric-literals": "error",
|
|
91
|
+
"prefer-object-has-own": "error",
|
|
92
|
+
"prefer-object-spread": "error",
|
|
93
|
+
"prefer-promise-reject-errors": "error",
|
|
94
|
+
"prefer-regex-literals": "error",
|
|
95
|
+
"prefer-rest-params": "error",
|
|
96
|
+
"prefer-spread": "error",
|
|
97
|
+
"prefer-template": "error",
|
|
98
|
+
"preserve-caught-error": "error",
|
|
99
|
+
radix: "error",
|
|
100
|
+
"symbol-description": "error",
|
|
101
|
+
yoda: "error",
|
|
102
|
+
},
|
|
103
|
+
}, {
|
|
104
|
+
name: "@whiteeclipse/toolchain/eslint/core/tests",
|
|
105
|
+
files: ["**/*.{spec,test}.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
|
|
106
|
+
rules: {
|
|
107
|
+
"func-names": "off",
|
|
108
|
+
"no-magic-numbers": "off",
|
|
109
|
+
"prefer-named-capture-group": "off",
|
|
110
|
+
},
|
|
111
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 - White Eclipse
|
|
3
|
+
* Released under the MIT Licence.
|
|
4
|
+
*/
|
|
5
|
+
import { defineConfig } from "eslint/config";
|
|
6
|
+
import ImportX from "eslint-plugin-import-x";
|
|
7
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
name: "@whiteeclipse/toolchain/eslint/import-x",
|
|
10
|
+
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
|
|
11
|
+
plugins: { "import-x": ImportX },
|
|
12
|
+
settings: {
|
|
13
|
+
"import-x/resolver-next": [
|
|
14
|
+
createTypeScriptImportResolver({
|
|
15
|
+
bun: true,
|
|
16
|
+
project: ["tsconfig.json", "apps/*/tsconfig.json", "packages/*/*/tsconfig.json"],
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
"import-x/no-deprecated": "error",
|
|
22
|
+
"import-x/no-extraneous-dependencies": "error",
|
|
23
|
+
"import-x/no-cycle": "error",
|
|
24
|
+
"import-x/no-relative-packages": "error",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 - White Eclipse
|
|
3
|
+
* Released under the MIT Licence.
|
|
4
|
+
*/
|
|
5
|
+
import { defineConfig } from "eslint/config";
|
|
6
|
+
import JSDoc from "eslint-plugin-jsdoc";
|
|
7
|
+
/**
|
|
8
|
+
* Matches an explicit React element reference at an AST property path.
|
|
9
|
+
*
|
|
10
|
+
* @param path The return annotation's property path.
|
|
11
|
+
* @returns A selector for imported or React-qualified ReactElement types.
|
|
12
|
+
*/
|
|
13
|
+
function reactElementAt(path) {
|
|
14
|
+
return `:matches([${path}.type="TSTypeReference"][${path}.typeName.name="ReactElement"], [${path}.type="TSTypeReference"][${path}.typeName.left.name="React"][${path}.typeName.right.name="ReactElement"])`;
|
|
15
|
+
}
|
|
16
|
+
// Nullable returns must contain exactly one React element type and null.
|
|
17
|
+
const annotation = "returnType.typeAnnotation";
|
|
18
|
+
const nullable = `[${annotation}.type="TSUnionType"][${annotation}.types.length=2]`;
|
|
19
|
+
const elementReturn = `:matches(${reactElementAt(annotation)}, ${nullable}${reactElementAt(`${annotation}.types.0`)}[${annotation}.types.1.type="TSNullKeyword"], ${nullable}${reactElementAt(`${annotation}.types.1`)}[${annotation}.types.0.type="TSNullKeyword"])`;
|
|
20
|
+
const componentName = "/^[A-Z][A-Za-z0-9]*$/";
|
|
21
|
+
const assignedFunction = ":matches(ArrowFunctionExpression, FunctionExpression)";
|
|
22
|
+
const componentFunction = `:matches(FunctionDeclaration[id.name=${componentName}], FunctionExpression[id.name=${componentName}], VariableDeclarator[id.name=${componentName}] > ${assignedFunction}, AssignmentExpression[left.name=${componentName}] > ${assignedFunction}, PropertyDefinition[key.name=${componentName}] > ${assignedFunction})${elementReturn}`;
|
|
23
|
+
// Optional component summaries must not require prop or return-tag boilerplate.
|
|
24
|
+
const documentedFunctions = [
|
|
25
|
+
`FunctionDeclaration:not(${componentFunction})`,
|
|
26
|
+
`FunctionExpression:not(${componentFunction})`,
|
|
27
|
+
`ArrowFunctionExpression:not(${componentFunction})`,
|
|
28
|
+
];
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
name: "@whiteeclipse/toolchain/eslint/jsdoc",
|
|
31
|
+
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}"],
|
|
32
|
+
plugins: { jsdoc: JSDoc },
|
|
33
|
+
extends: [JSDoc.configs["flat/recommended-typescript-error"]],
|
|
34
|
+
rules: {
|
|
35
|
+
"jsdoc/check-tag-names": ["error", { definedTags: ["rejects"] }],
|
|
36
|
+
"jsdoc/require-jsdoc": [
|
|
37
|
+
"error",
|
|
38
|
+
{
|
|
39
|
+
publicOnly: false,
|
|
40
|
+
enableFixer: false,
|
|
41
|
+
require: {
|
|
42
|
+
FunctionDeclaration: false,
|
|
43
|
+
ArrowFunctionExpression: false,
|
|
44
|
+
FunctionExpression: false,
|
|
45
|
+
MethodDefinition: true,
|
|
46
|
+
},
|
|
47
|
+
contexts: [
|
|
48
|
+
"TSInterfaceDeclaration",
|
|
49
|
+
`FunctionDeclaration:not(${componentFunction})`,
|
|
50
|
+
`:matches(VariableDeclarator, AssignmentExpression, ExportDefaultDeclaration, PropertyDefinition) > ${assignedFunction}:not(${componentFunction})`,
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
"jsdoc/require-description": "error",
|
|
55
|
+
"jsdoc/require-param": [
|
|
56
|
+
"error",
|
|
57
|
+
{ checkDestructured: false, enableFixer: false, contexts: documentedFunctions },
|
|
58
|
+
],
|
|
59
|
+
"jsdoc/require-returns": ["error", { forceReturnsWithAsync: true, contexts: documentedFunctions }],
|
|
60
|
+
"jsdoc/require-throws": "error",
|
|
61
|
+
"jsdoc/require-throws-description": "error",
|
|
62
|
+
"jsdoc/require-rejects": "error",
|
|
63
|
+
"jsdoc/no-types": "error",
|
|
64
|
+
"jsdoc/tag-lines": ["error", "always", { count: 0, startLines: 1 }],
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 - White Eclipse
|
|
3
|
+
* Released under the MIT Licence.
|
|
4
|
+
*/
|
|
5
|
+
import { defineConfig } from "eslint/config";
|
|
6
|
+
import TypeScript from "typescript-eslint";
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
name: "@whiteeclipse/toolchain/eslint/typescript",
|
|
9
|
+
files: ["**/*.{ts,tsx,mts,cts}"],
|
|
10
|
+
extends: [...TypeScript.configs.strictTypeChecked, ...TypeScript.configs.stylisticTypeChecked],
|
|
11
|
+
languageOptions: {
|
|
12
|
+
parserOptions: {
|
|
13
|
+
projectService: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
"@typescript-eslint/no-floating-promises": ["error", { ignoreVoid: true }],
|
|
18
|
+
"class-methods-use-this": "off",
|
|
19
|
+
"@typescript-eslint/class-methods-use-this": ["error", { ignoreOverrideMethods: true }],
|
|
20
|
+
"@typescript-eslint/consistent-type-exports": ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
21
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
22
|
+
"error",
|
|
23
|
+
{ prefer: "type-imports", fixStyle: "inline-type-imports", disallowTypeAnnotations: true },
|
|
24
|
+
],
|
|
25
|
+
"default-param-last": "off",
|
|
26
|
+
"@typescript-eslint/default-param-last": "error",
|
|
27
|
+
"@typescript-eslint/explicit-module-boundary-types": "error",
|
|
28
|
+
"max-params": "off",
|
|
29
|
+
"@typescript-eslint/max-params": ["error", { max: 4 }],
|
|
30
|
+
"@typescript-eslint/method-signature-style": ["error", "method"],
|
|
31
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
32
|
+
"no-magic-numbers": "off",
|
|
33
|
+
"@typescript-eslint/no-magic-numbers": [
|
|
34
|
+
"error",
|
|
35
|
+
{
|
|
36
|
+
ignore: [0, 1],
|
|
37
|
+
ignoreArrayIndexes: true,
|
|
38
|
+
ignoreNumericLiteralTypes: true,
|
|
39
|
+
ignoreTypeIndexes: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
"@typescript-eslint/no-useless-empty-export": "error",
|
|
43
|
+
"@typescript-eslint/promise-function-async": ["error", { allowAny: false }],
|
|
44
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
45
|
+
"@typescript-eslint/strict-void-return": "error",
|
|
46
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
47
|
+
"@typescript-eslint/no-unsafe-type-assertion": "error",
|
|
48
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
49
|
+
"@typescript-eslint/strict-boolean-expressions": ["error", { allowString: false, allowNumber: false }],
|
|
50
|
+
"@typescript-eslint/restrict-template-expressions": ["error", { allowNumber: true }],
|
|
51
|
+
"@typescript-eslint/no-unused-expressions": ["error", { allowTaggedTemplates: true }],
|
|
52
|
+
"no-unused-vars": ["off"],
|
|
53
|
+
"@typescript-eslint/no-unused-vars": ["error", {
|
|
54
|
+
args: "all",
|
|
55
|
+
argsIgnorePattern: "^_",
|
|
56
|
+
varsIgnorePattern: "^_",
|
|
57
|
+
caughtErrors: "all",
|
|
58
|
+
caughtErrorsIgnorePattern: "^_",
|
|
59
|
+
destructuredArrayIgnorePattern: "^_",
|
|
60
|
+
}],
|
|
61
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
62
|
+
},
|
|
63
|
+
}, {
|
|
64
|
+
name: "@whiteeclipse/toolchain/eslint/typescript/tests",
|
|
65
|
+
files: ["**/*.{spec,test}.{ts,tsx,mts,cts}"],
|
|
66
|
+
rules: { "@typescript-eslint/no-magic-numbers": "off" },
|
|
67
|
+
});
|
package/dist/prettier.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 - White Eclipse
|
|
3
|
+
* Released under the MIT Licence.
|
|
4
|
+
*/
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
/** Shared formatting options, retaining Arcadia's formatting and package key order. */
|
|
8
|
+
const config = {
|
|
9
|
+
printWidth: 120,
|
|
10
|
+
tabWidth: 4,
|
|
11
|
+
useTabs: false,
|
|
12
|
+
semi: true,
|
|
13
|
+
singleQuote: false,
|
|
14
|
+
quoteProps: "as-needed",
|
|
15
|
+
jsxSingleQuote: false,
|
|
16
|
+
trailingComma: "all",
|
|
17
|
+
bracketSpacing: true,
|
|
18
|
+
bracketSameLine: false,
|
|
19
|
+
arrowParens: "avoid",
|
|
20
|
+
endOfLine: "lf",
|
|
21
|
+
plugins: [
|
|
22
|
+
require.resolve("prettier-plugin-packagejson"),
|
|
23
|
+
// Tailwind's plugin must be last to preserve compatibility with other plugins.
|
|
24
|
+
require.resolve("prettier-plugin-tailwindcss"),
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@whiteeclipse/toolchain",
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
|
+
"description": "Shared ESLint and Prettier configuration of White Eclipse.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/whiteeclipse-studio/hypatia.git",
|
|
8
|
+
"directory": "packages/libraries/toolchain"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./eslint": {
|
|
14
|
+
"types": "./dist/eslint/index.d.ts",
|
|
15
|
+
"development": "./dist/eslint/index.js",
|
|
16
|
+
"default": "./dist/eslint/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./prettier": {
|
|
19
|
+
"types": "./dist/prettier.d.ts",
|
|
20
|
+
"development": "./dist/prettier.js",
|
|
21
|
+
"default": "./dist/prettier.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
26
|
+
"lint": "bun --conditions=development run --bun eslint .",
|
|
27
|
+
"prepack": "bun run build",
|
|
28
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@eslint/js": "10.0.1",
|
|
32
|
+
"eslint-import-resolver-typescript": "4.4.5",
|
|
33
|
+
"eslint-plugin-import-x": "4.17.1",
|
|
34
|
+
"eslint-plugin-jsdoc": "65.4.2",
|
|
35
|
+
"globals": "17.13.0",
|
|
36
|
+
"prettier-plugin-packagejson": "3.0.3",
|
|
37
|
+
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
38
|
+
"typescript-eslint": "8.72.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@total-typescript/ts-reset": "0.6.1",
|
|
42
|
+
"eslint": "10.13.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"eslint": "10.13.0",
|
|
46
|
+
"prettier": "3.9.10",
|
|
47
|
+
"typescript": "6.0.3"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"tag": "alpha"
|
|
52
|
+
}
|
|
53
|
+
}
|