@evertondgn/solid-tooling 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Éverton Toffanetto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,53 @@
1
- # Temporary Holding Version
1
+ # @evertondgn/solid-tooling
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Lint, formatador e base do TypeScript para aplicações SolidJS construídas com
4
+ Vite+. O pacote é distribuído compilado: o Node recusa TypeScript dentro de
5
+ `node_modules`, e o Vite+ carrega a configuração em Node.
6
+
7
+ ## Instalação
8
+
9
+ ```bash
10
+ vp add -D @evertondgn/solid-tooling
11
+ ```
12
+
13
+ A aplicação também declara o `vite-plus` e o `@inlang/paraglide-js`. O Oxlint
14
+ resolve os plugins a partir da configuração da aplicação, e o plugin do
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.
17
+
18
+ ## Uso
19
+
20
+ ```ts
21
+ // vite.config.ts
22
+ import { fmt } from '@evertondgn/solid-tooling/fmt'
23
+ import { lint } from '@evertondgn/solid-tooling/lint'
24
+ import { defineConfig } from 'vite-plus'
25
+
26
+ export default defineConfig({ fmt, lint })
27
+ ```
28
+
29
+ ```json
30
+ // tsconfig.json
31
+ {
32
+ "extends": "@evertondgn/solid-tooling/tsconfig.base.json"
33
+ }
34
+ ```
35
+
36
+ `paths`, `include` e `types` continuam no `tsconfig.json` da aplicação.
37
+
38
+ ## Entradas
39
+
40
+ | Entrada | Conteúdo |
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 |
50
+
51
+ O preset pressupõe o layout das aplicações derivadas do `boilerplate_solidjs`:
52
+ código em `src/`, ferramentas em `tooling/` e as camadas descritas no guia de
53
+ arquitetura da aplicação.
@@ -0,0 +1,2 @@
1
+ declare const architecturePolicy: import("vite-plus/lint/plugins").Plugin;
2
+ export { architecturePolicy as default };
@@ -0,0 +1,82 @@
1
+ import { n as resolveProjectPath, t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
2
+ import { definePlugin, defineRule } from "vite-plus/lint/plugins";
3
+ import path from "node:path";
4
+ // src/architecturePolicy/index.ts
5
+ const UI = [
6
+ "atoms",
7
+ "molecules",
8
+ "organisms",
9
+ "components"
10
+ ];
11
+ const FORBIDDEN = {
12
+ base: [
13
+ "primitives",
14
+ ...UI,
15
+ "routes",
16
+ "entry"
17
+ ],
18
+ primitives: [
19
+ ...UI,
20
+ "routes",
21
+ "entry"
22
+ ],
23
+ atoms: ["molecules", "organisms"],
24
+ molecules: ["organisms"]
25
+ };
26
+ function layer(file) {
27
+ if (file === "tooling" || file.startsWith("tooling/")) return "tooling";
28
+ if (file.startsWith("paraglide/")) return "base";
29
+ if (!file.startsWith("src/")) return void 0;
30
+ if (/^src\/tests(?:\/|$)|\/__tests__(?:\/|$)|\.test(?:\.[cm]?[jt]sx?)?$/u.test(file)) return "test";
31
+ if (/^src\/(?:@types|constants|helpers|data|infra|theme|i18n)(?:\/|$)/u.test(file)) return "base";
32
+ if (/^src\/primitives(?:\/|$)/u.test(file)) return "primitives";
33
+ const level = /^src\/components\/(?<level>atoms|molecules|organisms)(?:\/|\.[cm]?[jt]sx?$|$)/u.exec(file)?.groups?.level;
34
+ if (level === "atoms" || level === "molecules" || level === "organisms") return level;
35
+ if (/^src\/components(?:\/|$)/u.test(file)) return "components";
36
+ if (/^src\/routes(?:\/|$)/u.test(file)) return "routes";
37
+ if (/^src\/(?:App|Document|entry-server|entry-client|router|middleware)(?:\.[cm]?[jt]sx?$|\/|$)/u.test(file)) return "entry";
38
+ return "source";
39
+ }
40
+ const layerImports = defineRule({
41
+ meta: {
42
+ type: "problem",
43
+ schema: [],
44
+ messages: { forbidden: "A camada {{from}} não pode depender de {{to}} ({{target}}). Consulte as regras de camadas em docs/architecture.md." }
45
+ },
46
+ create(context) {
47
+ const from = layer(path.relative(context.cwd, context.filename).split(path.sep).join("/"));
48
+ if (!from || from === "test" || from === "tooling") return {};
49
+ const forbidden = FORBIDDEN[from] ?? [];
50
+ function check(node) {
51
+ const specifier = readStaticSpecifier(node);
52
+ if (specifier === void 0) return;
53
+ const target = resolveProjectPath({
54
+ specifier,
55
+ filename: context.filename,
56
+ root: context.cwd
57
+ });
58
+ const to = layer(target);
59
+ if (to && (to === "test" || to === "tooling" || forbidden.includes(to))) context.report({
60
+ node,
61
+ messageId: "forbidden",
62
+ data: {
63
+ from,
64
+ to,
65
+ target
66
+ }
67
+ });
68
+ }
69
+ return {
70
+ ImportDeclaration: check,
71
+ ExportNamedDeclaration: check,
72
+ ExportAllDeclaration: check,
73
+ ImportExpression: check,
74
+ TSImportType: check
75
+ };
76
+ }
77
+ });
78
+ const architecturePolicy = definePlugin({
79
+ meta: { name: "architecture" },
80
+ rules: { "layer-imports": layerImports }
81
+ });
82
+ export { architecturePolicy as default };
@@ -0,0 +1,2 @@
1
+ declare const backendPlugin: import("vite-plus/lint/plugins").Plugin;
2
+ export { backendPlugin as default };
@@ -0,0 +1,37 @@
1
+ import { t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
2
+ import { n as RENDER_INTEGRITY_MODULE } from "./constants-DwOmJ9No.mjs";
3
+ import { definePlugin, defineRule } from "vite-plus/lint/plugins";
4
+ // src/backendPolicy/plugin.ts
5
+ const RENDER_INTEGRITY = new RegExp(RENDER_INTEGRITY_MODULE, "u");
6
+ function staticImportRule({ matches, message }) {
7
+ return defineRule({
8
+ meta: {
9
+ type: "problem",
10
+ schema: [],
11
+ messages: { staticImport: message }
12
+ },
13
+ create(context) {
14
+ return { ImportExpression(node) {
15
+ const specifier = readStaticSpecifier(node);
16
+ if (specifier !== void 0 && matches(specifier)) context.report({
17
+ node,
18
+ messageId: "staticImport"
19
+ });
20
+ } };
21
+ }
22
+ });
23
+ }
24
+ const backendPlugin = definePlugin({
25
+ meta: { name: "backend" },
26
+ rules: {
27
+ "static-solid-imports": staticImportRule({
28
+ matches: (specifier) => specifier === "@solidjs/web" || specifier.startsWith("@solidjs/web/"),
29
+ message: "Use import estático de @solidjs/web e seus subcaminhos para preservar as restrições de APIs privilegiadas."
30
+ }),
31
+ "static-render-integrity-imports": staticImportRule({
32
+ matches: (specifier) => RENDER_INTEGRITY.test(specifier),
33
+ message: "Use import estático de renderIntegrity para preservar a restrição de observeRenderFailures."
34
+ })
35
+ }
36
+ });
37
+ export { backendPlugin as default };
@@ -0,0 +1,7 @@
1
+ // src/backendPolicy/constants.ts
2
+ const RELATIVE_IMPORT_RESTRICTION = {
3
+ regex: String.raw`^(\.\./){4,}`,
4
+ message: "Imports relativos podem subir no máximo três níveis. Use o alias @/ para caminhos mais distantes."
5
+ };
6
+ const RENDER_INTEGRITY_MODULE = String.raw`(?:^|/)renderIntegrity(?:/index(?:\.ts)?)?$`;
7
+ export { RENDER_INTEGRITY_MODULE as n, RELATIVE_IMPORT_RESTRICTION as t };
@@ -0,0 +1,2 @@
1
+ export declare function cssFilenameError(file: string): string | undefined;
2
+ export declare const cssFilename: import("vite-plus/lint/plugins").Rule;
@@ -0,0 +1,40 @@
1
+ import { n as resolveProjectPath, t as readStaticSpecifier } from "./import-specifier-C7HWhMXB.mjs";
2
+ import { defineRule } from "vite-plus/lint/plugins";
3
+ import path from "node:path";
4
+ // src/css/css-filename.ts
5
+ function cssFilenameError(file) {
6
+ const normalized = file.split("\\").join("/");
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 nomeCamelCase.css dentro de src/theme/.";
9
+ return basename === "styles.module.css" ? void 0 : "Use styles.module.css fora de src/theme/, inclusive nas rotas.";
10
+ }
11
+ const cssFilename = defineRule({
12
+ meta: {
13
+ type: "problem",
14
+ schema: []
15
+ },
16
+ create(context) {
17
+ function check(node) {
18
+ const specifier = readStaticSpecifier(node);
19
+ if (specifier === void 0) return;
20
+ const relative = resolveProjectPath({
21
+ specifier,
22
+ filename: context.filename,
23
+ root: context.cwd
24
+ });
25
+ if (!relative.startsWith("src/") || !relative.endsWith(".css")) return;
26
+ const message = cssFilenameError(relative);
27
+ if (message) context.report({
28
+ node,
29
+ message
30
+ });
31
+ }
32
+ return {
33
+ ImportDeclaration: check,
34
+ ExportNamedDeclaration: check,
35
+ ExportAllDeclaration: check,
36
+ ImportExpression: check
37
+ };
38
+ }
39
+ });
40
+ export { cssFilename, cssFilenameError };
package/dist/fmt.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ import { UserConfig } from "vite-plus";
2
+ export declare const fmt: NonNullable<UserConfig['fmt']>;
package/dist/fmt.mjs ADDED
@@ -0,0 +1,34 @@
1
+ // src/fmt.ts
2
+ const fmt = {
3
+ printWidth: 80,
4
+ singleQuote: true,
5
+ semi: false,
6
+ trailingComma: "none",
7
+ arrowParens: "avoid",
8
+ proseWrap: "always",
9
+ sortPackageJson: false,
10
+ embeddedLanguageFormatting: "off",
11
+ sortImports: { groups: [
12
+ "builtin",
13
+ "external",
14
+ ["internal", "subpath"],
15
+ [
16
+ "parent",
17
+ "sibling",
18
+ "index"
19
+ ],
20
+ "style",
21
+ "unknown"
22
+ ] },
23
+ ignorePatterns: [
24
+ "public/**",
25
+ "src/assets/**",
26
+ "src/@types/routes.d.ts",
27
+ "**/*.svg",
28
+ "*.lock",
29
+ "AGENTS.md",
30
+ ".agents/**",
31
+ ".claude/**"
32
+ ]
33
+ };
34
+ export { fmt };
@@ -0,0 +1,25 @@
1
+ import path from "node:path";
2
+ // src/lint/import-specifier.ts
3
+ function resolveAbsolute({ specifier, filename, root }) {
4
+ if (specifier.startsWith("@paraglide/")) return path.resolve(root, "paraglide", specifier.slice(11));
5
+ if (specifier.startsWith("@/")) return path.resolve(root, "src", specifier.slice(2));
6
+ if (specifier.startsWith("/src/")) return path.resolve(root, specifier.slice(1));
7
+ if (specifier.startsWith(".")) return path.resolve(path.dirname(filename), specifier);
8
+ }
9
+ function readStaticSpecifier({ source }) {
10
+ if (source?.type === "Literal") return typeof source.value === "string" ? source.value : void 0;
11
+ if (source?.type !== "TemplateLiteral" || source.expressions.length > 0) return;
12
+ const cooked = source.quasis[0]?.value.cooked;
13
+ return typeof cooked === "string" ? cooked : void 0;
14
+ }
15
+ function resolveProjectPath({ specifier, filename, root }) {
16
+ const [clean = ""] = specifier.replaceAll("\\", "/").split(/[?#]/u);
17
+ const absolute = resolveAbsolute({
18
+ specifier: clean,
19
+ filename,
20
+ root
21
+ });
22
+ if (absolute === void 0) return "";
23
+ return path.relative(root, absolute).split(path.sep).join("/");
24
+ }
25
+ export { resolveProjectPath as n, readStaticSpecifier as t };
@@ -0,0 +1,2 @@
1
+ import { UserConfig } from "vite-plus";
2
+ export declare const lint: NonNullable<UserConfig['lint']>;