diff --git a/scripts/project-lint.ts b/scripts/project-lint.ts index 1b99c1f..0c747b7 100644 --- a/scripts/project-lint.ts +++ b/scripts/project-lint.ts @@ -166,11 +166,6 @@ const noAssetImportsRule: ProjectRule = { * rules it turns off, and options that differ from a rule's defaults. */ const rules: DummyRuleMap = { - // Its own rules. - "project/no-disable-comments": "error", - "project/no-asset-imports": "error", - - // Options. // The explicit-types template's `camelcase` stand-in: no `_` inside a name // once leading and trailing ones are trimmed, unless it has no lowercase // ASCII letter (UPPER_SNAKE). @@ -191,6 +186,7 @@ const rules: DummyRuleMap = { ], // Single capital type parameters, which explicit-types requires, may be one letter. "id-length": ["error", { exceptionPatterns: ["^[A-Z]$"] }], + // Option tweaks. "one-var": ["error", "never"], "no-use-before-define": ["error", { functions: false }], "func-style": ["error", "declaration", { allowArrowFunctions: true }], @@ -204,8 +200,10 @@ const rules: DummyRuleMap = { "max-statements": ["error", 32], "import/max-dependencies": ["error", { max: 13 }], "unicorn/max-nested-calls": ["error", { max: 4 }], - - // Collides with another rule, a plugin config, or Oxfmt. + // No lint suppression and only `.ts` imports, as in the plugin template. + "project/no-disable-comments": "error", + "project/no-asset-imports": "error", + // Off, collides with a repo or plugin rule, Oxfmt, or another category rule: // Collides with `#private`: members are public unless marked so. "typescript/explicit-member-accessibility": "off", // Collides with `typescript/prefer-readonly-parameter-types` being off. @@ -253,23 +251,20 @@ const rules: DummyRuleMap = { "unicorn/no-array-reduce": "off", // Collides with literal Gitea Actions `${{ }}` expressions in workflow strings. "no-template-curly-in-string": "off", - - // Node code: this action runs on Node. + // Node code, everywhere: this action runs on Node. // Node built-ins are the action's runtime. "import/no-nodejs-modules": "off", // Command-line entry points set their exit status. "unicorn/no-process-exit": "off", // The action reports to the job log through the console. "no-console": "off", - // PENDING USER: union members are values in profiles.json, the Gitea API, // and posted comments; renaming them changes behavior. "explicit-types/upper-snake-string-unions": "off", // PENDING USER: a fitting `name` needs a constructor and changes logged // error names. "unicorn/custom-error-definition": "off", - - // Too much churn. + // Off, too much churn: // Literal numbers read better than a constant per use. "no-magic-numbers": "off", // Keys follow meaning, not the alphabet. @@ -296,9 +291,22 @@ const rules: DummyRuleMap = { "no-continue": "off", }; +/** Node code (`vite.config.ts` and `scripts/`), spread into `overrides`. */ +const nodeRules: DummyRuleMap = { + // Vite and the Oxlint plugin host read a default export. + "import/no-default-export": "off", + // Node code: tooling imports Node's built-ins. + "import/no-nodejs-modules": "off", + // Node code: a CLI exits with a status. + "unicorn/no-process-exit": "off", + // Node code: a CLI reports through the console. + "no-console": "off", +}; + /** * The repo-local plugin, namespace `project`: its own rules, enabled as - * `project/`, and `configs.project`, the rule list above. + * `project/`, `configs.project`, the rule list above, and + * `configs.node`, the Node code offs. */ const plugin = { meta: { name: "project" }, @@ -306,7 +314,7 @@ const plugin = { "no-disable-comments": noDisableCommentsRule, "no-asset-imports": noAssetImportsRule, }, - configs: { project: { rules } }, + configs: { project: { rules }, node: { rules: nodeRules } }, }; export default plugin; diff --git a/vite.config.ts b/vite.config.ts index eb968fb..24bb629 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,20 +19,16 @@ export default defineConfig({ perf: "error", style: "error", restriction: "error", - nursery: "off", }, rules: { - ...explicitTypes.configs.concrete.rules, - ...explicitTypes.configs.naming.rules, - ...explicitTypes.configs.absence.rules, - ...importStructure.configs.modules.rules, + ...explicitTypes.configs.all.rules, + ...importStructure.configs.all.rules, ...projectLint.configs.project.rules, }, overrides: [ { - // Vite+ and Oxlint load these through their default export. - files: ["vite.config.ts", "scripts/project-lint.ts"], - rules: { "import/no-default-export": "off" }, + files: ["vite.config.ts", "scripts/**"], + rules: projectLint.configs.node.rules, }, ], options: {