@evertondgn/solid-tooling 0.1.0 → 0.2.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 +230 -25
- package/dist/architecture-plugin.mjs +1 -1
- package/dist/backend-plugin.mjs +3 -3
- package/dist/{constants-DwOmJ9No.mjs → constants-Jqvtbvxu.mjs} +1 -1
- package/dist/css-filename.mjs +2 -2
- package/dist/lint.mjs +7 -7
- package/dist/project-plugin.mjs +11 -11
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
1
|
# @evertondgn/solid-tooling
|
|
2
2
|
|
|
3
|
-
Lint,
|
|
4
|
-
|
|
5
|
-
`node_modules`, e o Vite+ carrega a configuração em Node.
|
|
3
|
+
Lint preset, formatter config and TypeScript base for SolidJS 2 applications
|
|
4
|
+
built with [Vite+](https://viteplus.dev/guide/).
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
The package contains the lint, format and TypeScript setup of
|
|
7
|
+
[boilerplate_solidjs](https://github.com/everton-dgn/boilerplate_solidjs), a
|
|
8
|
+
SolidJS application template. Applications created from it install the package
|
|
9
|
+
instead of copying the files, so a rule change reaches them through a version
|
|
10
|
+
update.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
The application installs three packages next to this one:
|
|
15
|
+
|
|
16
|
+
| Package | Why |
|
|
17
|
+
| ---------------------- | ----------------------------------------------------------- |
|
|
18
|
+
| `vite-plus` | Runs lint and format, and provides the Oxlint plugin API |
|
|
19
|
+
| `@inlang/paraglide-js` | The preset registers its lint plugin, resolved from the app |
|
|
20
|
+
| `typescript` | The preset turns on type-aware linting and type checking |
|
|
21
|
+
|
|
22
|
+
`vite-plus` and `@inlang/paraglide-js` are peer dependencies, pinned to the
|
|
23
|
+
exact versions the package is tested with. Install the versions listed in its
|
|
24
|
+
`peerDependencies`. `typescript` is not a peer dependency: the package is tested
|
|
25
|
+
with the version in its `devDependencies`.
|
|
26
|
+
|
|
27
|
+
`eslint-plugin-solid` comes with the package, so the application does not
|
|
28
|
+
declare it.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
`vp` is the Vite+ CLI. An application built with Vite+ already has `vite-plus`
|
|
33
|
+
and `typescript`, so it only adds this package:
|
|
8
34
|
|
|
9
35
|
```bash
|
|
10
36
|
vp add -D @evertondgn/solid-tooling
|
|
11
37
|
```
|
|
12
38
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Paraglide precisa acompanhar a versão que ela usa. O `eslint-plugin-solid` vem
|
|
16
|
-
como dependência do pacote e dispensa declaração.
|
|
39
|
+
An application without `@inlang/paraglide-js` adds it too, in the version the
|
|
40
|
+
package asks for:
|
|
17
41
|
|
|
18
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm view @evertondgn/solid-tooling peerDependencies
|
|
44
|
+
vp add -D @inlang/paraglide-js@<version>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
19
48
|
|
|
20
49
|
```ts
|
|
21
50
|
// vite.config.ts
|
|
@@ -29,25 +58,201 @@ export default defineConfig({ fmt, lint })
|
|
|
29
58
|
```json
|
|
30
59
|
// tsconfig.json
|
|
31
60
|
{
|
|
32
|
-
"extends": "@evertondgn/solid-tooling/tsconfig.base.json"
|
|
61
|
+
"extends": "@evertondgn/solid-tooling/tsconfig.base.json",
|
|
62
|
+
"compilerOptions": {
|
|
63
|
+
"paths": { "@/*": ["./src/*"] }
|
|
64
|
+
},
|
|
65
|
+
"include": ["src", "vite.config.ts"]
|
|
33
66
|
}
|
|
34
67
|
```
|
|
35
68
|
|
|
36
|
-
`
|
|
69
|
+
`vp check`, `vp lint` and `vp fmt` read both configs from `vite.config.ts`.
|
|
70
|
+
|
|
71
|
+
## Project layout the preset expects
|
|
72
|
+
|
|
73
|
+
The rules match file paths relative to the folder where lint runs, so run it
|
|
74
|
+
from the application root. They know these locations:
|
|
75
|
+
|
|
76
|
+
| Path | Meaning |
|
|
77
|
+
| --------------------------------------------- | -------------------------------------------------------- |
|
|
78
|
+
| `src/` | Application code. The `@/` alias points here |
|
|
79
|
+
| `src/routes/` | Pages. Each page may have a `seo.ts` module |
|
|
80
|
+
| `src/components/{atoms,molecules,organisms}/` | UI layers |
|
|
81
|
+
| `src/primitives/` | Shared primitives |
|
|
82
|
+
| `src/infra/server/` | Backend adapters and server error handling |
|
|
83
|
+
| `src/theme/` | Global CSS |
|
|
84
|
+
| `src/tests/pages/<Page>/` | End-to-end tests, one folder per page |
|
|
85
|
+
| `paraglide/` | Generated i18n modules. The `@paraglide/` alias |
|
|
86
|
+
| `tooling/` | Project scripts and their tests, written for `node:test` |
|
|
87
|
+
|
|
88
|
+
An application with another layout can still use the preset, but it has to
|
|
89
|
+
override the rules that do not fit. See
|
|
90
|
+
[Changing the preset](#changing-the-preset).
|
|
91
|
+
|
|
92
|
+
## What the lint preset turns on
|
|
93
|
+
|
|
94
|
+
- Oxlint plugins: `import`, `jsx-a11y`, `node`, `oxc`, `promise`, `typescript`,
|
|
95
|
+
`unicorn` and `vitest`.
|
|
96
|
+
- JavaScript plugins: `solid`, `paraglide`, `vite-plus` and the three plugins of
|
|
97
|
+
this package (`project`, `backend`, `architecture`).
|
|
98
|
+
- Type-aware rules and type checking (`typeAware`, `typeCheck`).
|
|
99
|
+
- Warnings fail the run (`denyWarnings`), and an unused disable directive is an
|
|
100
|
+
error.
|
|
101
|
+
|
|
102
|
+
Every rule is listed by name in the preset. No Oxlint category is enabled, so an
|
|
103
|
+
Oxlint update does not add rules on its own.
|
|
104
|
+
|
|
105
|
+
### Rules of this package
|
|
106
|
+
|
|
107
|
+
| Rule | What it enforces |
|
|
108
|
+
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `project/css-modules-import` | A CSS Module is imported as the default binding `S` |
|
|
110
|
+
| `project/css-filename` | A CSS file imported from `src/` is named `styles.module.css`, or `camelCase.css` inside `src/theme/` |
|
|
111
|
+
| `project/test-filename` | A test file sits in `__tests__` next to its module and is named after it, plus the environment: `Button/__tests__/Button.dom.test.tsx` |
|
|
112
|
+
| `project/no-export-list` | Exports sit on the declaration. `export { a, b }` is only allowed with `from` |
|
|
113
|
+
| `project/seo-module` | A route `seo.ts` exports only `seo`. It has no relative value import, no value import from `src/routes/`, no computed `import()` and no `import.meta.glob` |
|
|
114
|
+
| `backend/static-solid-imports` | No `import()` of `@solidjs/web` or its subpaths |
|
|
115
|
+
| `backend/static-render-integrity-imports` | No `import()` of the `renderIntegrity` module |
|
|
116
|
+
| `architecture/layer-imports` | Lower layers do not import upper ones, and production code does not import tests or `tooling/` |
|
|
117
|
+
|
|
118
|
+
These rules read import specifiers as text. They resolve relative paths and the
|
|
119
|
+
`@/`, `@paraglide/` and `/src/` prefixes. An `import()` with a computed path and
|
|
120
|
+
any other alias are not checked, except in `seo.ts`, where a computed `import()`
|
|
121
|
+
is an error.
|
|
122
|
+
|
|
123
|
+
`architecture/layer-imports` checks these directions:
|
|
124
|
+
|
|
125
|
+
- The base layer (`src/@types`, `constants`, `helpers`, `data`, `infra`,
|
|
126
|
+
`theme`, `i18n` and `paraglide/`) does not import primitives, components,
|
|
127
|
+
routes or entry files.
|
|
128
|
+
- `src/primitives` does not import components, routes or entry files.
|
|
129
|
+
- Atoms do not import molecules or organisms, and molecules do not import
|
|
130
|
+
organisms.
|
|
131
|
+
- No production file imports a test or `tooling/`.
|
|
132
|
+
|
|
133
|
+
The entry files are `App`, `Document`, `entry-server`, `entry-client`, `router`
|
|
134
|
+
and `middleware`, at the root of `src/`.
|
|
135
|
+
|
|
136
|
+
`project/test-filename` accepts these names:
|
|
137
|
+
|
|
138
|
+
- `Name.<environment>.test.ts(x)` in `src/`, where the environment is `node`,
|
|
139
|
+
`dom`, `browser` or `e2e`.
|
|
140
|
+
- `Name.test-d.ts(x)` in `src/`, for type tests.
|
|
141
|
+
- `Name.test.ts` in `tooling/`.
|
|
142
|
+
|
|
143
|
+
`Name` is the folder that holds `__tests__`. A qualifier may follow it:
|
|
144
|
+
`Button.focus.dom.test.tsx`. End-to-end tests are the exception: they live in
|
|
145
|
+
`src/tests/pages/<Page>/` and are named after the page.
|
|
146
|
+
|
|
147
|
+
### Backend restrictions
|
|
148
|
+
|
|
149
|
+
Inside `src/`, the preset also restricts what code can reach:
|
|
150
|
+
|
|
151
|
+
- `console` is not allowed. `src/infra/server/logServerFailure/index.ts` is the
|
|
152
|
+
only module that may call `console.error`.
|
|
153
|
+
- `fetch`, `XMLHttpRequest`, `WebSocket` and `EventSource` are not allowed.
|
|
154
|
+
`src/infra/server/requestJson/index.ts` is the only module that may call
|
|
155
|
+
`fetch`.
|
|
156
|
+
- The Node transports (`http`, `https`, `http2`, `net`, `tls`, `undici`) cannot
|
|
157
|
+
be imported.
|
|
158
|
+
- `markSafeError` and `SAFE_ERROR` can only be imported in
|
|
159
|
+
`src/infra/server/publicErrors/index.ts`.
|
|
160
|
+
- `configureServerErrors` from `@solidjs/web`, the
|
|
161
|
+
`@solidjs/web/server-functions` subpath and `observeRenderFailures` from the
|
|
162
|
+
application's `renderIntegrity` module can only be imported in
|
|
163
|
+
`src/infra/server/configureServerErrors/index.ts`.
|
|
164
|
+
- A relative import goes up at most three levels. Use `@/` beyond that.
|
|
165
|
+
|
|
166
|
+
Test files and `.d.ts` files are exempt from all of these except the relative
|
|
167
|
+
import limit.
|
|
168
|
+
|
|
169
|
+
## Changing the preset
|
|
170
|
+
|
|
171
|
+
`lint` and `fmt` are plain objects. Spread them and replace what the application
|
|
172
|
+
needs:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
// vite.config.ts
|
|
176
|
+
import { fmt } from '@evertondgn/solid-tooling/fmt'
|
|
177
|
+
import { lint } from '@evertondgn/solid-tooling/lint'
|
|
178
|
+
import { defineConfig } from 'vite-plus'
|
|
179
|
+
|
|
180
|
+
export default defineConfig({
|
|
181
|
+
fmt,
|
|
182
|
+
lint: {
|
|
183
|
+
...lint,
|
|
184
|
+
ignorePatterns: [...(lint.ignorePatterns ?? []), 'generated/**'],
|
|
185
|
+
rules: { ...lint.rules, 'eslint/max-params': 'off' }
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Do not replace `lint.jsPlugins`. It registers the JavaScript plugins listed
|
|
191
|
+
above, and a rule whose plugin is missing from it fails to resolve.
|
|
192
|
+
|
|
193
|
+
To turn a rule off for some files only, add an entry to `lint.overrides` and
|
|
194
|
+
keep the existing ones:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
overrides: [
|
|
198
|
+
...(lint.overrides ?? []),
|
|
199
|
+
{
|
|
200
|
+
files: ['src/tests/pages/Checkout/**'],
|
|
201
|
+
rules: { 'project/test-filename': 'off' }
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Entry points
|
|
207
|
+
|
|
208
|
+
| Entry | Content |
|
|
209
|
+
| ----------------------- | ------------------------------------------------------------------------- |
|
|
210
|
+
| `./lint` | `lint`: the lint preset, with the plugins below registered |
|
|
211
|
+
| `./fmt` | `fmt`: the formatter config |
|
|
212
|
+
| `./tsconfig.base.json` | Compiler options, without application paths |
|
|
213
|
+
| `./project-plugin` | The `project` rules |
|
|
214
|
+
| `./backend-plugin` | The `backend` rules |
|
|
215
|
+
| `./architecture-plugin` | The `architecture` rule |
|
|
216
|
+
| `./solid-plugin` | Re-export of `eslint-plugin-solid` |
|
|
217
|
+
| `./css-filename` | `cssFilenameError(path)`, the CSS naming check, for a script outside lint |
|
|
218
|
+
|
|
219
|
+
An application only imports `./lint`, `./fmt` and `./tsconfig.base.json`. The
|
|
220
|
+
plugin entries exist because Oxlint loads plugins by specifier, from the
|
|
221
|
+
application.
|
|
222
|
+
|
|
223
|
+
## Formatter
|
|
224
|
+
|
|
225
|
+
`fmt` sets 80 columns, single quotes, no semicolons, no trailing commas, wrapped
|
|
226
|
+
prose in Markdown and sorted imports. It ignores `public/`, `src/assets/`,
|
|
227
|
+
generated route types, SVG and lock files.
|
|
228
|
+
|
|
229
|
+
## TypeScript base
|
|
230
|
+
|
|
231
|
+
`tsconfig.base.json` targets ES2024 with bundler resolution, keeps JSX for the
|
|
232
|
+
Solid compiler (`jsxImportSource: @solidjs/web`), emits nothing and turns on the
|
|
233
|
+
unused code and unchecked index checks. It has no `paths`, `include` or `types`:
|
|
234
|
+
those depend on the application and stay in its `tsconfig.json`.
|
|
235
|
+
|
|
236
|
+
## Known limits
|
|
237
|
+
|
|
238
|
+
- The package ships compiled JavaScript. Node refuses to run TypeScript from
|
|
239
|
+
`node_modules`, and Vite+ loads `vite.config.ts` in Node.
|
|
240
|
+
- `project/test-filename` has no options. Test folders without a module, such as
|
|
241
|
+
the page tests in `src/tests/pages/`, are listed inside the package with the
|
|
242
|
+
names used in boilerplate_solidjs. For any other folder of that kind, turn the
|
|
243
|
+
rule off in `lint.overrides`, as shown in
|
|
244
|
+
[Changing the preset](#changing-the-preset).
|
|
245
|
+
- The Paraglide plugin is always registered, so `@inlang/paraglide-js` has to be
|
|
246
|
+
installed even in an application without translations.
|
|
247
|
+
- Some rule messages point to `docs/architecture.md` and `AGENTS.md`. Those
|
|
248
|
+
files belong to the application created from boilerplate_solidjs.
|
|
249
|
+
|
|
250
|
+
## Versions
|
|
37
251
|
|
|
38
|
-
|
|
252
|
+
The package follows semantic versioning. Below 1.0.0, a breaking change raises
|
|
253
|
+
the minor version. Each release is listed in the
|
|
254
|
+
[changelog](https://github.com/everton-dgn/solidjs_base/blob/main/packages/solid-tooling/CHANGELOG.md).
|
|
39
255
|
|
|
40
|
-
|
|
41
|
-
| ----------------------- | ----------------------------------------------------------- |
|
|
42
|
-
| `./lint` | Preset de lint, com os plugins abaixo já registrados |
|
|
43
|
-
| `./fmt` | Configuração do formatador |
|
|
44
|
-
| `./project-plugin` | Regras de exports, nomes de arquivos de teste e de CSS, SEO |
|
|
45
|
-
| `./backend-plugin` | Imports estáticos das APIs privilegiadas do servidor |
|
|
46
|
-
| `./architecture-plugin` | Dependências entre camadas |
|
|
47
|
-
| `./solid-plugin` | Reexport do `eslint-plugin-solid` |
|
|
48
|
-
| `./css-filename` | Regra de nome de arquivo CSS, para o script de lint de CSS |
|
|
49
|
-
| `./tsconfig.base.json` | Opções do compilador sem caminhos da aplicação |
|
|
256
|
+
## License
|
|
50
257
|
|
|
51
|
-
|
|
52
|
-
código em `src/`, ferramentas em `tooling/` e as camadas descritas no guia de
|
|
53
|
-
arquitetura da aplicação.
|
|
258
|
+
MIT
|
|
@@ -41,7 +41,7 @@ const layerImports = defineRule({
|
|
|
41
41
|
meta: {
|
|
42
42
|
type: "problem",
|
|
43
43
|
schema: [],
|
|
44
|
-
messages: { forbidden: "
|
|
44
|
+
messages: { forbidden: "Layer {{from}} must not depend on {{to}} ({{target}}). See the layer rules in docs/architecture.md." }
|
|
45
45
|
},
|
|
46
46
|
create(context) {
|
|
47
47
|
const from = layer(path.relative(context.cwd, context.filename).split(path.sep).join("/"));
|
package/dist/backend-plugin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
|
|
2
|
-
import { n as RENDER_INTEGRITY_MODULE } from "./constants-
|
|
2
|
+
import { n as RENDER_INTEGRITY_MODULE } from "./constants-Jqvtbvxu.mjs";
|
|
3
3
|
import { definePlugin, defineRule } from "vite-plus/lint/plugins";
|
|
4
4
|
// src/backendPolicy/plugin.ts
|
|
5
5
|
const RENDER_INTEGRITY = new RegExp(RENDER_INTEGRITY_MODULE, "u");
|
|
@@ -26,11 +26,11 @@ const backendPlugin = definePlugin({
|
|
|
26
26
|
rules: {
|
|
27
27
|
"static-solid-imports": staticImportRule({
|
|
28
28
|
matches: (specifier) => specifier === "@solidjs/web" || specifier.startsWith("@solidjs/web/"),
|
|
29
|
-
message: "Use import
|
|
29
|
+
message: "Use a static import for @solidjs/web and its subpaths: the import restrictions on markSafeError and configureServerErrors cannot check import()."
|
|
30
30
|
}),
|
|
31
31
|
"static-render-integrity-imports": staticImportRule({
|
|
32
32
|
matches: (specifier) => RENDER_INTEGRITY.test(specifier),
|
|
33
|
-
message: "Use import
|
|
33
|
+
message: "Use a static import for renderIntegrity: the import restriction on observeRenderFailures cannot check import()."
|
|
34
34
|
})
|
|
35
35
|
}
|
|
36
36
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/backendPolicy/constants.ts
|
|
2
2
|
const RELATIVE_IMPORT_RESTRICTION = {
|
|
3
3
|
regex: String.raw`^(\.\./){4,}`,
|
|
4
|
-
message: "
|
|
4
|
+
message: "Relative imports may go up at most three levels. Use the @/ alias for more distant paths."
|
|
5
5
|
};
|
|
6
6
|
const RENDER_INTEGRITY_MODULE = String.raw`(?:^|/)renderIntegrity(?:/index(?:\.ts)?)?$`;
|
|
7
7
|
export { RENDER_INTEGRITY_MODULE as n, RELATIVE_IMPORT_RESTRICTION as t };
|
package/dist/css-filename.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import path from "node:path";
|
|
|
5
5
|
function cssFilenameError(file) {
|
|
6
6
|
const normalized = file.split("\\").join("/");
|
|
7
7
|
const basename = path.posix.basename(normalized);
|
|
8
|
-
if (normalized.startsWith("src/theme/")) return /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/u.test(basename.slice(0, -4)) ? void 0 : "Use
|
|
9
|
-
return basename === "styles.module.css" ? void 0 : "Use styles.module.css
|
|
8
|
+
if (normalized.startsWith("src/theme/")) return /^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/u.test(basename.slice(0, -4)) ? void 0 : "Use camelCaseName.css inside src/theme/.";
|
|
9
|
+
return basename === "styles.module.css" ? void 0 : "Use styles.module.css outside src/theme/, including in routes.";
|
|
10
10
|
}
|
|
11
11
|
const cssFilename = defineRule({
|
|
12
12
|
meta: {
|
package/dist/lint.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as RENDER_INTEGRITY_MODULE, t as RELATIVE_IMPORT_RESTRICTION } from "./constants-
|
|
1
|
+
import { n as RENDER_INTEGRITY_MODULE, t as RELATIVE_IMPORT_RESTRICTION } from "./constants-Jqvtbvxu.mjs";
|
|
2
2
|
// src/backendPolicy/index.ts
|
|
3
3
|
const NETWORK = [
|
|
4
4
|
"fetch",
|
|
@@ -16,21 +16,21 @@ const GLOBALS = [
|
|
|
16
16
|
const SAFE_ERRORS = {
|
|
17
17
|
name: "@solidjs/web",
|
|
18
18
|
importNames: ["markSafeError", "SAFE_ERROR"],
|
|
19
|
-
message: "Use createPublicError;
|
|
19
|
+
message: "Use createPublicError; only publicErrors may mark an error as public."
|
|
20
20
|
};
|
|
21
21
|
const SERVER_ERROR_HOOK = {
|
|
22
22
|
name: "@solidjs/web",
|
|
23
23
|
importNames: ["configureServerErrors"],
|
|
24
|
-
message: "
|
|
24
|
+
message: "Only src/infra/server/configureServerErrors/index.ts may import this: server error handling is configured in that module."
|
|
25
25
|
};
|
|
26
26
|
const SERVER_CONFIG = ["@solidjs/web/server-functions", "@solidjs/web/server-functions/server"].map((name) => ({
|
|
27
27
|
name,
|
|
28
|
-
message: "
|
|
28
|
+
message: "Only src/infra/server/configureServerErrors/index.ts may import this: server error handling is configured in that module."
|
|
29
29
|
}));
|
|
30
30
|
const RENDER_OBSERVER = {
|
|
31
31
|
regex: RENDER_INTEGRITY_MODULE,
|
|
32
32
|
importNames: ["observeRenderFailures"],
|
|
33
|
-
message: "
|
|
33
|
+
message: "Only configureServerErrors may declare that render failures are observed."
|
|
34
34
|
};
|
|
35
35
|
const TRANSPORTS = [
|
|
36
36
|
"http",
|
|
@@ -41,7 +41,7 @@ const TRANSPORTS = [
|
|
|
41
41
|
"undici"
|
|
42
42
|
].flatMap((name) => [name, `node:${name}`]).map((name) => ({
|
|
43
43
|
name,
|
|
44
|
-
message: "
|
|
44
|
+
message: "Node transports cannot be imported in src/. Use requestJson for HTTP, or an adapter in src/infra/server/ wrapped in protectServerOperation."
|
|
45
45
|
}));
|
|
46
46
|
function imports({ paths, patterns = [] }) {
|
|
47
47
|
return { "eslint/no-restricted-imports": ["error", {
|
|
@@ -59,7 +59,7 @@ function globals({ names, properties = names }) {
|
|
|
59
59
|
"eslint/no-restricted-properties": ["error", ...GLOBALS.flatMap((object) => properties.map((property) => ({
|
|
60
60
|
object,
|
|
61
61
|
property,
|
|
62
|
-
message: property === "console" ? "
|
|
62
|
+
message: property === "console" ? "Log failures only through logServerFailure." : "Call the backend through requestJson, or through an adapter in src/infra/server/ wrapped in protectServerOperation."
|
|
63
63
|
})))]
|
|
64
64
|
};
|
|
65
65
|
}
|
package/dist/project-plugin.mjs
CHANGED
|
@@ -7,7 +7,7 @@ const noExportList = defineRule({
|
|
|
7
7
|
meta: {
|
|
8
8
|
type: "suggestion",
|
|
9
9
|
schema: [],
|
|
10
|
-
messages: { inlineExport: "
|
|
10
|
+
messages: { inlineExport: "Export on the declaration itself (export function, export const, export type) instead of using export { ... }. An export list is only allowed in a re-export with from." }
|
|
11
11
|
},
|
|
12
12
|
create(context) {
|
|
13
13
|
return { ExportNamedDeclaration(node) {
|
|
@@ -32,10 +32,10 @@ const seoModule = defineRule({
|
|
|
32
32
|
type: "problem",
|
|
33
33
|
schema: [],
|
|
34
34
|
messages: {
|
|
35
|
-
onlySeo: "
|
|
36
|
-
localImport: "
|
|
37
|
-
computedImport: "
|
|
38
|
-
globImport: "
|
|
35
|
+
onlySeo: "seo.ts may export only seo. The route manifest loads the route export of every page in the initial bundle, and seo.ts goes with it, so keep the page body in index.tsx (see the page modules section of AGENTS.md).",
|
|
36
|
+
localImport: "seo.ts must not import values from relative paths or from src/routes/: whatever it imports goes into the initial bundle. Use import type, or keep the code in index.tsx (see the page modules section of AGENTS.md).",
|
|
37
|
+
computedImport: "seo.ts must not use import() with a computed path: the rule cannot tell whether the target is local. Keep the page body in index.tsx (see the page modules section of AGENTS.md).",
|
|
38
|
+
globImport: "seo.ts must not use import.meta.glob: Vite turns it into imports of every module the pattern matches. Keep the page body in index.tsx (see the page modules section of AGENTS.md)."
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
create(context) {
|
|
@@ -155,13 +155,13 @@ function testFilenameError(file) {
|
|
|
155
155
|
});
|
|
156
156
|
const candidate = dotted ? `${DOTTED_SUBJECT}${basename.slice(dotted.length)}` : basename;
|
|
157
157
|
const match = normalized.startsWith("tooling/") ? /^(?<subject>[^.]+)(?<qualifiers>(?:\.[a-z][a-zA-Z0-9]*)*)\.test\.ts$/u.exec(candidate) : /^(?<subject>[^.]+)(?<qualifiers>(?:\.[a-z][a-zA-Z0-9]*)*)(?:\.(?<environment>node|dom|browser|e2e)\.test|\.test-d)\.tsx?$/u.exec(candidate);
|
|
158
|
-
if (!match?.groups) return "
|
|
158
|
+
if (!match?.groups) return "In src/, name the test Name[.qualifier].<node|dom|browser|e2e>.test.ts(x), or Name[.qualifier].test-d.ts(x) for a type test. In tooling/, use Name[.qualifier].test.ts.";
|
|
159
159
|
const { environment } = match.groups;
|
|
160
160
|
const subject = dotted ?? match.groups.subject;
|
|
161
|
-
if (inPages && environment !== "e2e") return "
|
|
162
|
-
if (environment === "e2e" && (!inPages || !subjects[directory])) return "
|
|
163
|
-
if (!expected) return "
|
|
164
|
-
if (!subject || !expected.includes(subject)) return `Use
|
|
161
|
+
if (inPages && environment !== "e2e") return "Page tests must use the e2e environment.";
|
|
162
|
+
if (environment === "e2e" && (!inPages || !subjects[directory])) return "Place e2e tests in src/tests/pages/<Page>/. The accepted pages are listed in @evertondgn/solid-tooling; for another page, turn off project/test-filename for its folder in lint.overrides.";
|
|
163
|
+
if (!expected) return "Place the test in a __tests__ folder inside the module folder, as in Button/__tests__/Button.dom.test.tsx. For a test folder without a module, turn off project/test-filename for its files in lint.overrides.";
|
|
164
|
+
if (!subject || !expected.includes(subject)) return `Use the exact name of the subject under test: ${expected.join(", ")}. Qualifiers use a dot and camelCase.`;
|
|
165
165
|
}
|
|
166
166
|
const testFilename = defineRule({
|
|
167
167
|
meta: {
|
|
@@ -183,7 +183,7 @@ const cssModulesImport = defineRule({
|
|
|
183
183
|
meta: {
|
|
184
184
|
type: "suggestion",
|
|
185
185
|
schema: [],
|
|
186
|
-
messages: { useS: "
|
|
186
|
+
messages: { useS: "Import CSS Modules as S: import S from \"./styles.module.css\"." }
|
|
187
187
|
},
|
|
188
188
|
create(context) {
|
|
189
189
|
return { ImportDeclaration(node) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evertondgn/solid-tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Lint, formatter and TypeScript presets for SolidJS applications built with Vite+.",
|
|
5
5
|
"author": "Éverton Toffanetto",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"build": "vp pack",
|
|
40
40
|
"dev": "vp pack --watch",
|
|
41
41
|
"test": "vp run test-rules",
|
|
42
|
-
"test:tarball": "vp run test-tarball"
|
|
43
|
-
"prepublishOnly": "vp pack"
|
|
42
|
+
"test:tarball": "vp run test-tarball"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
45
|
"eslint-plugin-solid": "0.19.0"
|