@dbtlr/tooling 0.1.0 → 0.1.1
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/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/vite-plus.d.mts.map +1 -1
- package/dist/vite-plus.mjs +1 -0
- package/dist/vite-plus.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/tooling-config.ts"],"mappings":";;;;;;KASK,UAAA;AAAA,KAEA,oBAAA;EAAA,SACM,IAAA,GAAO,UAAA;EAAA,SACP,KAAA,GAAQ,UAAA;EAAA,SACR,IAAA;EAAA,SACA,IAAA,GAAO,UAAA;EAAA,SACP,IAAA,GAAO,IAAA,CAAK,mBAAA;EAAA,SACZ,GAAA,GAAM,UAAA;EAAA,SACN,MAAA,GAAS,UAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/tooling-config.ts"],"mappings":";;;;;;KASK,UAAA;AAAA,KAEA,oBAAA;EAAA,SACM,IAAA,GAAO,UAAA;EAAA,SACP,KAAA,GAAQ,UAAA;EAAA,SACR,IAAA;EAAA,SACA,IAAA,GAAO,UAAA;EAAA,SACP,IAAA,GAAO,IAAA,CAAK,mBAAA;EAAA,SACZ,GAAA,GAAM,UAAA;EAAA,SACN,MAAA,GAAS,UAAA;AAAA;AAAA,cAUd,aAAA,GAAiB,OAAA,GAAS,oBAAyB,yBAAA,UAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { viteReactApp } from "./vite.mjs";
|
|
|
4
4
|
import { vitestNode, vitestReact } from "./vitest.mjs";
|
|
5
5
|
import { defineConfig } from "vite-plus";
|
|
6
6
|
//#region src/tooling-config.ts
|
|
7
|
-
const isScopedTarget = (target) => Array.isArray(target);
|
|
7
|
+
const isScopedTarget = (target) => Array.isArray(target) && target.length > 0;
|
|
8
8
|
const toolingConfig = (options = {}) => {
|
|
9
9
|
const { node, react, test, pack, lint, fmt, staged } = options;
|
|
10
10
|
const scoped = isScopedTarget(node) || isScopedTarget(react);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/tooling-config.ts"],"sourcesContent":["import { defineConfig } from 'vite-plus';\n\nimport { compactObject } from './types.js';\nimport type { JsonObject } from './types.js';\nimport { vitePlusBase, vitePlusPackage } from './vite-plus.js';\nimport type { VitePlusLintOptions } from './vite-plus.js';\nimport { viteReactApp } from './vite.js';\nimport { vitestNode, vitestReact } from './vitest.js';\n\ntype LintTarget = boolean | readonly string[];\n\ntype ToolingConfigOptions = {\n readonly node?: LintTarget;\n readonly react?: LintTarget;\n readonly test?: 'node' | 'react' | false;\n readonly pack?: JsonObject;\n readonly lint?: Omit<VitePlusLintOptions, 'node' | 'react'>;\n readonly fmt?: JsonObject;\n readonly staged?: JsonObject | false;\n};\n\n// A glob list scopes a target to a monorepo's packages; a bare `true
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/tooling-config.ts"],"sourcesContent":["import { defineConfig } from 'vite-plus';\n\nimport { compactObject } from './types.js';\nimport type { JsonObject } from './types.js';\nimport { vitePlusBase, vitePlusPackage } from './vite-plus.js';\nimport type { VitePlusLintOptions } from './vite-plus.js';\nimport { viteReactApp } from './vite.js';\nimport { vitestNode, vitestReact } from './vitest.js';\n\ntype LintTarget = boolean | readonly string[];\n\ntype ToolingConfigOptions = {\n readonly node?: LintTarget;\n readonly react?: LintTarget;\n readonly test?: 'node' | 'react' | false;\n readonly pack?: JsonObject;\n readonly lint?: Omit<VitePlusLintOptions, 'node' | 'react'>;\n readonly fmt?: JsonObject;\n readonly staged?: JsonObject | false;\n};\n\n// A non-empty glob list scopes a target to a monorepo's packages; a bare `true`\n// means the whole single project. Globs => this is a monorepo root: lint only, no\n// test/vite. An empty list is the target being off (per the LintTarget contract),\n// not a monorepo root, so it must not suppress the test/vite blocks.\nconst isScopedTarget = (target: LintTarget | undefined): boolean =>\n Array.isArray(target) && target.length > 0;\n\nconst toolingConfig = (options: ToolingConfigOptions = {}) => {\n const { node, react, test, pack, lint, fmt, staged } = options;\n const scoped = isScopedTarget(node) || isScopedTarget(react);\n\n const baseOptions = compactObject({\n fmt,\n lint: { ...lint, node, react },\n staged,\n });\n const base =\n pack === undefined ? vitePlusBase(baseOptions) : vitePlusPackage({ ...baseOptions, pack });\n\n // Single-project react gets the vite react-app block; a monorepo root (any glob\n // target) does not — gated on `scoped` so it stays consistent with the test block.\n const viteApp = react === true && !scoped ? viteReactApp() : {};\n\n // Derive the test env from intent unless overridden; monorepo roots and\n // `test: false` carry no test block (members own their own test config).\n const testBlock = ((): JsonObject => {\n if (scoped || test === false) {\n return {};\n }\n const env = test ?? (react ? 'react' : 'node');\n return env === 'react' ? vitestReact() : vitestNode();\n })();\n\n return defineConfig({ ...base, ...viteApp, ...testBlock });\n};\n\nexport { toolingConfig };\nexport type { ToolingConfigOptions };\n"],"mappings":";;;;;;AAyBA,MAAM,kBAAkB,WACtB,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS;AAE3C,MAAM,iBAAiB,UAAgC,CAAC,MAAM;CAC5D,MAAM,EAAE,MAAM,OAAO,MAAM,MAAM,MAAM,KAAK,WAAW;CACvD,MAAM,SAAS,eAAe,IAAI,KAAK,eAAe,KAAK;CAE3D,MAAM,cAAc,cAAc;EAChC;EACA,MAAM;GAAE,GAAG;GAAM;GAAM;EAAM;EAC7B;CACF,CAAC;CACD,MAAM,OACJ,SAAS,KAAA,IAAY,aAAa,WAAW,IAAI,gBAAgB;EAAE,GAAG;EAAa;CAAK,CAAC;CAI3F,MAAM,UAAU,UAAU,QAAQ,CAAC,SAAS,aAAa,IAAI,CAAC;CAI9D,MAAM,mBAA+B;EACnC,IAAI,UAAU,SAAS,OACrB,OAAO,CAAC;EAGV,QADY,SAAS,QAAQ,UAAU,aACxB,UAAU,YAAY,IAAI,WAAW;CACtD,EAAA,CAAG;CAEH,OAAO,aAAa;EAAE,GAAG;EAAM,GAAG;EAAS,GAAG;CAAU,CAAC;AAC3D"}
|
package/dist/vite-plus.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plus.d.mts","names":[],"sources":["../src/vite-plus.ts"],"mappings":";;;KAQK,UAAA;AAAA,KAEA,mBAAA;EAAA,SACM,SAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA,GAAO,UAAA;EAAA,SACP,KAAA,GAAQ,UAAA;EAAA,SACR,KAAA,GAAQ,UAAA;EAAA,SACR,SAAA,YAAqB,UAAA;AAAA;AAAA,KAsC3B,sBAAA;EAAA,SACM,IAAA,GAAO,UAAA;EAAA,SACP,IAAA,GAAO,mBAAA;EAAA,SACP,GAAA,GAAM,UAAA;EAAA,SACN,MAAA,GAAS,UAAA;AAAA;AAAA,cA4Gd,YAAA,GAAgB,OAAA,GAAS,sBAAA,KAA8B,
|
|
1
|
+
{"version":3,"file":"vite-plus.d.mts","names":[],"sources":["../src/vite-plus.ts"],"mappings":";;;KAQK,UAAA;AAAA,KAEA,mBAAA;EAAA,SACM,SAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;EAAA,SACA,WAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA,GAAO,UAAA;EAAA,SACP,KAAA,GAAQ,UAAA;EAAA,SACR,KAAA,GAAQ,UAAA;EAAA,SACR,SAAA,YAAqB,UAAA;AAAA;AAAA,KAsC3B,sBAAA;EAAA,SACM,IAAA,GAAO,UAAA;EAAA,SACP,IAAA,GAAO,mBAAA;EAAA,SACP,GAAA,GAAM,UAAA;EAAA,SACN,MAAA,GAAS,UAAA;AAAA;AAAA,cA4Gd,YAAA,GAAgB,OAAA,GAAS,sBAAA,KAA8B,UAsBzD;AAAA,cAEE,eAAA,GAAmB,OAAA,GAAS,sBAAA,KAA8B,UAO9D"}
|
package/dist/vite-plus.mjs
CHANGED
package/dist/vite-plus.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plus.mjs","names":[],"sources":["../src/vite-plus.ts"],"sourcesContent":["import { compactObject } from './types.js';\nimport type { JsonObject } from './types.js';\n\n// A lint target — `node` or `react` — is a set of files the target applies to.\n// `true` means the whole project (config emitted at the top level); a list of\n// globs means just those files (config emitted as a scoped `overrides` fragment),\n// which is how a mixed-target monorepo's centralized root config addresses each\n// package. `false`/omitted/`[]` means the target is off.\ntype LintTarget = boolean | readonly string[];\n\ntype VitePlusLintOptions = {\n readonly typeAware?: boolean;\n readonly typeCheck?: boolean;\n readonly denyWarnings?: boolean;\n readonly maxWarnings?: number;\n readonly ignores?: readonly string[];\n readonly node?: LintTarget;\n readonly react?: LintTarget;\n readonly rules?: JsonObject;\n readonly overrides?: readonly JsonObject[];\n};\n\n// oxlint plugins enabled for a React target; the `react` plugin also carries the\n// rules-of-hooks / exhaustive-deps checks.\nconst REACT_PLUGINS = ['react', 'react-perf', 'jsx-a11y'] as const;\n\n// The rule tweaks a React target needs: the modern automatic JSX runtime (no\n// in-scope React import) and PascalCase component filenames.\nconst REACT_RULES: JsonObject = {\n 'react/react-in-jsx-scope': 'off',\n 'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],\n};\n\n// oxlint plugins enabled for a Node target.\nconst NODE_PLUGINS = ['node'] as const;\n\n// The rule a Node target needs: allow Node builtins (forbidden by the browser\n// baseline). Enabled alongside the `node` plugin. Consumed by both the\n// whole-project and glob-scoped node paths so they can't drift.\nconst NODE_RULES: JsonObject = {\n 'import/no-nodejs-modules': 'off',\n};\n\n// A target is \"whole project\" only when explicitly `true`.\nconst isWholeProject = (target: LintTarget | undefined): boolean => target === true;\n\n// Non-empty glob list → the target is scoped to those files; otherwise undefined.\nconst targetGlobs = (target: LintTarget | undefined): readonly string[] | undefined =>\n Array.isArray(target) && target.length > 0 ? target : undefined;\n\n// Build the scoped `overrides` fragment for a glob-targeted plugin set + rules.\nconst scopedOverride = (\n globs: readonly string[],\n plugins: readonly string[],\n rules: JsonObject,\n): JsonObject => ({ files: [...globs], plugins: [...plugins], rules: { ...rules } });\n\ntype VitePlusPackageOptions = {\n readonly pack?: JsonObject;\n readonly lint?: VitePlusLintOptions;\n readonly fmt?: JsonObject;\n readonly staged?: JsonObject | false;\n};\n\nconst vitePlusLint = (options: VitePlusLintOptions = {}): JsonObject => {\n const nodeWhole = isWholeProject(options.node);\n const reactWhole = isWholeProject(options.react);\n const nodeGlobs = targetGlobs(options.node);\n const reactGlobs = targetGlobs(options.react);\n\n // Glob-scoped targets become `overrides` fragments; they precede the standing\n // test-file override and any caller-supplied overrides.\n const targetOverrides: JsonObject[] = [\n ...(nodeGlobs ? [scopedOverride(nodeGlobs, NODE_PLUGINS, NODE_RULES)] : []),\n ...(reactGlobs ? [scopedOverride(reactGlobs, REACT_PLUGINS, REACT_RULES)] : []),\n ];\n\n return {\n categories: {\n correctness: 'error',\n nursery: 'off',\n pedantic: 'off',\n perf: 'error',\n restriction: 'off',\n style: 'warn',\n suspicious: 'error',\n },\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'coverage',\n '.turbo',\n '.vite',\n ...(options.ignores ?? []),\n ],\n // Strict by default: warnings fail, and type-aware lint + type checking run.\n // This is the house gate; opt out of any of them per-flag with `false`.\n options: compactObject({\n denyWarnings: options.denyWarnings ?? true,\n maxWarnings: options.maxWarnings,\n typeAware: options.typeAware ?? true,\n typeCheck: options.typeCheck ?? true,\n }),\n overrides: [\n ...targetOverrides,\n {\n files: [\n 'tests/**/*.ts',\n 'tests/**/*.tsx',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.spec.ts',\n '**/*.spec.tsx',\n ],\n rules: {\n 'max-statements': 'off',\n 'vitest/no-importing-vitest-globals': 'off',\n 'vitest/prefer-expect-assertions': 'off',\n 'vitest/prefer-importing-vitest-globals': 'off',\n },\n },\n ...(options.overrides ?? []),\n ],\n plugins: [\n 'typescript',\n 'import',\n 'eslint',\n 'unicorn',\n 'oxc',\n 'promise',\n 'vitest',\n // Whole-project targets enable plugins here; glob-scoped targets enable them\n // in their `overrides` fragment instead (see targetOverrides).\n ...(nodeWhole ? NODE_PLUGINS : []),\n ...(reactWhole ? REACT_PLUGINS : []),\n ],\n rules: {\n 'capitalized-comments': 'off',\n 'import/no-named-export': 'off',\n // Browser baseline forbids Node builtins; a whole-project node target lifts\n // this via NODE_RULES below, a glob-scoped one only inside its override.\n 'import/no-nodejs-modules': 'error',\n // Named exports are the house style (see import/no-named-export above), so\n // don't nudge single-export modules toward a default export.\n 'import/prefer-default-export': 'off',\n 'no-duplicate-imports': ['warn', { allowSeparateTypeImports: true }],\n 'no-magic-numbers': 'off',\n 'no-ternary': 'off',\n 'sort-imports': 'off',\n 'typescript/consistent-type-definitions': ['warn', 'type'],\n 'unicorn/no-null': 'off',\n // Ternaries are allowed (no-ternary off) but not forced; prefer-ternary would\n // rewrite else-if chains into nested ternaries, conflicting with unicorn/no-nested-ternary.\n 'unicorn/prefer-ternary': 'off',\n 'vitest/prefer-importing-vitest-globals': 'off',\n // Conflicts with vitest/prefer-strict-boolean-matchers; prefer strict toBe(true|false).\n // Disabled at base (not just in test files) so the conflict can't fire anywhere.\n 'vitest/prefer-to-be-falsy': 'off',\n 'vitest/prefer-to-be-truthy': 'off',\n // Whole-project targets only; glob-scoped rules live in their overrides.\n // Spread last so a whole-project node target overrides the baseline above.\n ...(nodeWhole ? NODE_RULES : {}),\n ...(reactWhole ? REACT_RULES : {}),\n ...options.rules,\n },\n };\n};\n\nconst vitePlusBase = (options: VitePlusPackageOptions = {}): JsonObject =>\n compactObject({\n fmt: {\n ignorePatterns: [\n 'pnpm-lock.yaml',\n 'bun.lock',\n 'dist/**',\n 'build/**',\n 'node_modules/**',\n 'coverage/**',\n '.turbo/**',\n '.vite/**',\n ],\n singleQuote: true,\n sortImports: { ignoreCase: true },\n ...options.fmt,\n },\n lint: vitePlusLint(options.lint),\n staged: options.staged === false ? undefined : (options.staged ?? { '*': 'vp check --fix' }),\n });\n\nconst vitePlusPackage = (options: VitePlusPackageOptions = {}): JsonObject => ({\n ...vitePlusBase(options),\n pack: {\n dts: { tsgo: true },\n exports: true,\n ...options.pack,\n },\n});\n\nexport { vitePlusBase, vitePlusPackage };\nexport type { VitePlusLintOptions, VitePlusPackageOptions };\n"],"mappings":";;AAwBA,MAAM,gBAAgB;CAAC;CAAS;CAAc;AAAU;AAIxD,MAAM,cAA0B;CAC9B,4BAA4B;CAC5B,yBAAyB,CAAC,QAAQ,EAAE,OAAO;EAAE,WAAW;EAAM,YAAY;CAAK,EAAE,CAAC;AACpF;AAGA,MAAM,eAAe,CAAC,MAAM;AAK5B,MAAM,aAAyB,EAC7B,4BAA4B,MAC9B;AAGA,MAAM,kBAAkB,WAA4C,WAAW;AAG/E,MAAM,eAAe,WACnB,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,IAAI,SAAS,KAAA;AAGxD,MAAM,kBACJ,OACA,SACA,WACgB;CAAE,OAAO,CAAC,GAAG,KAAK;CAAG,SAAS,CAAC,GAAG,OAAO;CAAG,OAAO,EAAE,GAAG,MAAM;AAAE;AASlF,MAAM,gBAAgB,UAA+B,CAAC,MAAkB;CACtE,MAAM,YAAY,eAAe,QAAQ,IAAI;CAC7C,MAAM,aAAa,eAAe,QAAQ,KAAK;CAC/C,MAAM,YAAY,YAAY,QAAQ,IAAI;CAC1C,MAAM,aAAa,YAAY,QAAQ,KAAK;CAI5C,MAAM,kBAAgC,CACpC,GAAI,YAAY,CAAC,eAAe,WAAW,cAAc,UAAU,CAAC,IAAI,CAAC,GACzE,GAAI,aAAa,CAAC,eAAe,YAAY,eAAe,WAAW,CAAC,IAAI,CAAC,CAC/E;CAEA,OAAO;EACL,YAAY;GACV,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K,iBAAiB;AAC5F,CAAC;AAEH,MAAM,mBAAmB,UAAkC,CAAC,OAAmB;CAC7E,GAAG,aAAa,OAAO;CACvB,MAAM;EACJ,KAAK,EAAE,MAAM,KAAK;EAClB,SAAS;EACT,GAAG,QAAQ;CACb;AACF"}
|
|
1
|
+
{"version":3,"file":"vite-plus.mjs","names":[],"sources":["../src/vite-plus.ts"],"sourcesContent":["import { compactObject } from './types.js';\nimport type { JsonObject } from './types.js';\n\n// A lint target — `node` or `react` — is a set of files the target applies to.\n// `true` means the whole project (config emitted at the top level); a list of\n// globs means just those files (config emitted as a scoped `overrides` fragment),\n// which is how a mixed-target monorepo's centralized root config addresses each\n// package. `false`/omitted/`[]` means the target is off.\ntype LintTarget = boolean | readonly string[];\n\ntype VitePlusLintOptions = {\n readonly typeAware?: boolean;\n readonly typeCheck?: boolean;\n readonly denyWarnings?: boolean;\n readonly maxWarnings?: number;\n readonly ignores?: readonly string[];\n readonly node?: LintTarget;\n readonly react?: LintTarget;\n readonly rules?: JsonObject;\n readonly overrides?: readonly JsonObject[];\n};\n\n// oxlint plugins enabled for a React target; the `react` plugin also carries the\n// rules-of-hooks / exhaustive-deps checks.\nconst REACT_PLUGINS = ['react', 'react-perf', 'jsx-a11y'] as const;\n\n// The rule tweaks a React target needs: the modern automatic JSX runtime (no\n// in-scope React import) and PascalCase component filenames.\nconst REACT_RULES: JsonObject = {\n 'react/react-in-jsx-scope': 'off',\n 'unicorn/filename-case': ['warn', { cases: { kebabCase: true, pascalCase: true } }],\n};\n\n// oxlint plugins enabled for a Node target.\nconst NODE_PLUGINS = ['node'] as const;\n\n// The rule a Node target needs: allow Node builtins (forbidden by the browser\n// baseline). Enabled alongside the `node` plugin. Consumed by both the\n// whole-project and glob-scoped node paths so they can't drift.\nconst NODE_RULES: JsonObject = {\n 'import/no-nodejs-modules': 'off',\n};\n\n// A target is \"whole project\" only when explicitly `true`.\nconst isWholeProject = (target: LintTarget | undefined): boolean => target === true;\n\n// Non-empty glob list → the target is scoped to those files; otherwise undefined.\nconst targetGlobs = (target: LintTarget | undefined): readonly string[] | undefined =>\n Array.isArray(target) && target.length > 0 ? target : undefined;\n\n// Build the scoped `overrides` fragment for a glob-targeted plugin set + rules.\nconst scopedOverride = (\n globs: readonly string[],\n plugins: readonly string[],\n rules: JsonObject,\n): JsonObject => ({ files: [...globs], plugins: [...plugins], rules: { ...rules } });\n\ntype VitePlusPackageOptions = {\n readonly pack?: JsonObject;\n readonly lint?: VitePlusLintOptions;\n readonly fmt?: JsonObject;\n readonly staged?: JsonObject | false;\n};\n\nconst vitePlusLint = (options: VitePlusLintOptions = {}): JsonObject => {\n const nodeWhole = isWholeProject(options.node);\n const reactWhole = isWholeProject(options.react);\n const nodeGlobs = targetGlobs(options.node);\n const reactGlobs = targetGlobs(options.react);\n\n // Glob-scoped targets become `overrides` fragments; they precede the standing\n // test-file override and any caller-supplied overrides.\n const targetOverrides: JsonObject[] = [\n ...(nodeGlobs ? [scopedOverride(nodeGlobs, NODE_PLUGINS, NODE_RULES)] : []),\n ...(reactGlobs ? [scopedOverride(reactGlobs, REACT_PLUGINS, REACT_RULES)] : []),\n ];\n\n return {\n categories: {\n correctness: 'error',\n nursery: 'off',\n pedantic: 'off',\n perf: 'error',\n restriction: 'off',\n style: 'warn',\n suspicious: 'error',\n },\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'coverage',\n '.turbo',\n '.vite',\n ...(options.ignores ?? []),\n ],\n // Strict by default: warnings fail, and type-aware lint + type checking run.\n // This is the house gate; opt out of any of them per-flag with `false`.\n options: compactObject({\n denyWarnings: options.denyWarnings ?? true,\n maxWarnings: options.maxWarnings,\n typeAware: options.typeAware ?? true,\n typeCheck: options.typeCheck ?? true,\n }),\n overrides: [\n ...targetOverrides,\n {\n files: [\n 'tests/**/*.ts',\n 'tests/**/*.tsx',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.spec.ts',\n '**/*.spec.tsx',\n ],\n rules: {\n 'max-statements': 'off',\n 'vitest/no-importing-vitest-globals': 'off',\n 'vitest/prefer-expect-assertions': 'off',\n 'vitest/prefer-importing-vitest-globals': 'off',\n },\n },\n ...(options.overrides ?? []),\n ],\n plugins: [\n 'typescript',\n 'import',\n 'eslint',\n 'unicorn',\n 'oxc',\n 'promise',\n 'vitest',\n // Whole-project targets enable plugins here; glob-scoped targets enable them\n // in their `overrides` fragment instead (see targetOverrides).\n ...(nodeWhole ? NODE_PLUGINS : []),\n ...(reactWhole ? REACT_PLUGINS : []),\n ],\n rules: {\n 'capitalized-comments': 'off',\n 'import/no-named-export': 'off',\n // Browser baseline forbids Node builtins; a whole-project node target lifts\n // this via NODE_RULES below, a glob-scoped one only inside its override.\n 'import/no-nodejs-modules': 'error',\n // Named exports are the house style (see import/no-named-export above), so\n // don't nudge single-export modules toward a default export.\n 'import/prefer-default-export': 'off',\n 'no-duplicate-imports': ['warn', { allowSeparateTypeImports: true }],\n 'no-magic-numbers': 'off',\n 'no-ternary': 'off',\n 'sort-imports': 'off',\n 'typescript/consistent-type-definitions': ['warn', 'type'],\n 'unicorn/no-null': 'off',\n // Ternaries are allowed (no-ternary off) but not forced; prefer-ternary would\n // rewrite else-if chains into nested ternaries, conflicting with unicorn/no-nested-ternary.\n 'unicorn/prefer-ternary': 'off',\n 'vitest/prefer-importing-vitest-globals': 'off',\n // Conflicts with vitest/prefer-strict-boolean-matchers; prefer strict toBe(true|false).\n // Disabled at base (not just in test files) so the conflict can't fire anywhere.\n 'vitest/prefer-to-be-falsy': 'off',\n 'vitest/prefer-to-be-truthy': 'off',\n // Whole-project targets only; glob-scoped rules live in their overrides.\n // Spread last so a whole-project node target overrides the baseline above.\n ...(nodeWhole ? NODE_RULES : {}),\n ...(reactWhole ? REACT_RULES : {}),\n ...options.rules,\n },\n };\n};\n\nconst vitePlusBase = (options: VitePlusPackageOptions = {}): JsonObject =>\n compactObject({\n fmt: {\n ignorePatterns: [\n 'pnpm-lock.yaml',\n 'bun.lock',\n // Generated by release-please/changesets — let the release tool own its\n // format instead of fighting it on every release PR.\n 'CHANGELOG.md',\n 'dist/**',\n 'build/**',\n 'node_modules/**',\n 'coverage/**',\n '.turbo/**',\n '.vite/**',\n ],\n singleQuote: true,\n sortImports: { ignoreCase: true },\n ...options.fmt,\n },\n lint: vitePlusLint(options.lint),\n staged: options.staged === false ? undefined : (options.staged ?? { '*': 'vp check --fix' }),\n });\n\nconst vitePlusPackage = (options: VitePlusPackageOptions = {}): JsonObject => ({\n ...vitePlusBase(options),\n pack: {\n dts: { tsgo: true },\n exports: true,\n ...options.pack,\n },\n});\n\nexport { vitePlusBase, vitePlusPackage };\nexport type { VitePlusLintOptions, VitePlusPackageOptions };\n"],"mappings":";;AAwBA,MAAM,gBAAgB;CAAC;CAAS;CAAc;AAAU;AAIxD,MAAM,cAA0B;CAC9B,4BAA4B;CAC5B,yBAAyB,CAAC,QAAQ,EAAE,OAAO;EAAE,WAAW;EAAM,YAAY;CAAK,EAAE,CAAC;AACpF;AAGA,MAAM,eAAe,CAAC,MAAM;AAK5B,MAAM,aAAyB,EAC7B,4BAA4B,MAC9B;AAGA,MAAM,kBAAkB,WAA4C,WAAW;AAG/E,MAAM,eAAe,WACnB,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,IAAI,SAAS,KAAA;AAGxD,MAAM,kBACJ,OACA,SACA,WACgB;CAAE,OAAO,CAAC,GAAG,KAAK;CAAG,SAAS,CAAC,GAAG,OAAO;CAAG,OAAO,EAAE,GAAG,MAAM;AAAE;AASlF,MAAM,gBAAgB,UAA+B,CAAC,MAAkB;CACtE,MAAM,YAAY,eAAe,QAAQ,IAAI;CAC7C,MAAM,aAAa,eAAe,QAAQ,KAAK;CAC/C,MAAM,YAAY,YAAY,QAAQ,IAAI;CAC1C,MAAM,aAAa,YAAY,QAAQ,KAAK;CAI5C,MAAM,kBAAgC,CACpC,GAAI,YAAY,CAAC,eAAe,WAAW,cAAc,UAAU,CAAC,IAAI,CAAC,GACzE,GAAI,aAAa,CAAC,eAA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Q,IAAI;CAC/B,QAAQ,QAAQ,WAAW,QAAQ,KAAA,IAAa,QAAQ,UAAU,EAAE,KAAK,iBAAiB;AAC5F,CAAC;AAEH,MAAM,mBAAmB,UAAkC,CAAC,OAAmB;CAC7E,GAAG,aAAa,OAAO;CACvB,MAAM;EACJ,KAAK,EAAE,MAAM,KAAK;EAClB,SAAS;EACT,GAAG,QAAQ;CACb;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbtlr/tooling",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Shared TypeScript, Vitest, and Vite+ config for dbtlr projects — one toolingConfig() entry point.",
|
|
5
5
|
"homepage": "https://github.com/dbtlr/ts-tooling#readme",
|
|
6
6
|
"bugs": "https://github.com/dbtlr/ts-tooling/issues",
|