Files
renovate/tools/lint/rules.ts
Jamie Tanna 134dc6cd38 chore(lint): add oxlint rule to block dev-dependency imports in production code (#45851)
As we've recently had a couple of cases where a `devDependency` has been
used in a production file, and CI hasn't caught it, we end up seeing
i.e.

    ERROR: unhandledRejection
           "err": {
             "code": "ERR_MODULE_NOT_FOUND",
             "message": "Cannot find package 'common-tags' imported from
                         /usr/local/renovate/dist/workers/repository/update/pr/index.js"
             }

(see 5ee51fdf39 and
1d33143727 for two cases this has happened
with)

One option for caching this is a linting rule, which stops runtime usage
in `lib/` on a dependency in `devDependencies`.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-09-10 14:59:09 +00:00

80 lines
4.0 KiB
TypeScript

import { definePlugin } from '@oxlint/plugins';
import codeblockInSpecFixtures from './rules/codeblock-in-spec-fixtures.ts';
import enforceTsExtension from './rules/enforce-ts-extension.ts';
import inlineSingleUseFixtures from './rules/inline-single-use-fixtures.ts';
import loggerErrKey from './rules/logger-err-key.ts';
import loggerStaticMessage from './rules/logger-static-message.ts';
import noDevDependencyImport from './rules/no-dev-dependency-import.ts';
import noExecShellOption from './rules/no-exec-shell-option.ts';
import noHardcodedDocsUrl from './rules/no-hardcoded-docs-url.ts';
import noHostRulesMock from './rules/no-host-rules-mock.ts';
import noNewUrl from './rules/no-new-url.ts';
import noNumberConstructor from './rules/no-number-constructor.ts';
import noRedundantMockReset from './rules/no-redundant-mock-reset.ts';
import noStatefulGlobalRegex from './rules/no-stateful-global-regex.ts';
import noToolsImport from './rules/no-tools-import.ts';
import noUnquotedExecInterpolation from './rules/no-unquoted-exec-interpolation.ts';
import noUnvalidatedPaginationUrl from './rules/no-unvalidated-pagination-url.ts';
import preferCoerceArray from './rules/prefer-coerce-array.ts';
import preferCoerceObject from './rules/prefer-coerce-object.ts';
import preferFakeShaInSpecs from './rules/prefer-fake-sha-in-specs.ts';
import preferFsUtil from './rules/prefer-fs-util.ts';
import preferIsHelpers from './rules/prefer-is-helpers.ts';
import preferIsObject from './rules/prefer-is-object.ts';
import preferJsonPipe from './rules/prefer-json-pipe.ts';
import preferLuxon from './rules/prefer-luxon.ts';
import preferNullishUtil from './rules/prefer-nullish-util.ts';
import preferPartialInSpecs from './rules/prefer-partial-in-specs.ts';
import preferStubEnv from './rules/prefer-stub-env.ts';
import requireRegexUtil from './rules/require-regex-util.ts';
import testRootDescribe from './rules/test-root-describe.ts';
import typesLocation from './rules/types-location.ts';
import v8IgnoreNoCount from './rules/v8-ignore-no-count.ts';
import v8IgnoreReason from './rules/v8-ignore-reason.ts';
import validateConfigWarningsAndErrors from './rules/validate-config-warnings-and-errors.ts';
import zodSchemaLocation from './rules/zod-schema-location.ts';
import zodSchemaNaming from './rules/zod-schema-naming.ts';
export default definePlugin({
meta: {
name: 'renovate',
},
rules: {
'codeblock-in-spec-fixtures': codeblockInSpecFixtures,
'enforce-ts-extension': enforceTsExtension,
'inline-single-use-fixtures': inlineSingleUseFixtures,
'logger-err-key': loggerErrKey,
'logger-static-message': loggerStaticMessage,
'no-dev-dependency-import': noDevDependencyImport,
'no-exec-shell-option': noExecShellOption,
'no-hardcoded-docs-url': noHardcodedDocsUrl,
'no-host-rules-mock': noHostRulesMock,
'no-new-url': noNewUrl,
'no-number-constructor': noNumberConstructor,
'no-redundant-mock-reset': noRedundantMockReset,
'no-stateful-global-regex': noStatefulGlobalRegex,
'no-tools-import': noToolsImport,
'no-unquoted-exec-interpolation': noUnquotedExecInterpolation,
'no-unvalidated-pagination-url': noUnvalidatedPaginationUrl,
'prefer-coerce-array': preferCoerceArray,
'prefer-coerce-object': preferCoerceObject,
'prefer-fake-sha-in-specs': preferFakeShaInSpecs,
'prefer-fs-util': preferFsUtil,
'prefer-json-pipe': preferJsonPipe,
'prefer-luxon': preferLuxon,
'prefer-is-helpers': preferIsHelpers,
'prefer-is-object': preferIsObject,
'prefer-nullish-util': preferNullishUtil,
'prefer-partial-in-specs': preferPartialInSpecs,
'prefer-stub-env': preferStubEnv,
'require-regex-util': requireRegexUtil,
'test-root-describe': testRootDescribe,
'types-location': typesLocation,
'v8-ignore-no-count': v8IgnoreNoCount,
'v8-ignore-reason': v8IgnoreReason,
'validate-config-warnings-and-errors': validateConfigWarningsAndErrors,
'zod-schema-location': zodSchemaLocation,
'zod-schema-naming': zodSchemaNaming,
},
});