diff --git a/eslint.config.mjs b/eslint.config.mjs index a116532..c26b7ec 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,12 +23,10 @@ export default tseslint.config( 'packages/eslint-plugin-typescript/src/configs/recommended-json/*', 'packages/eslint-plugin-typescript/src/configs/recommended-package/*', 'packages/eslint-plugin-typescript/src/configs/recommended-typescript/recommended-typescript.config.ts', - 'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/custom.ts', 'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/format.ts', 'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/import.ts', 'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/rxjs.ts', - 'packages/eslint-plugin-typescript/src/rules/*', - 'packages/eslint-plugin-typescript/src/util/*', + 'packages/eslint-plugin-typescript/src/rules/ts-config/*', 'scripts/*', '.eslintrc.format.js', 'eslint.config.mjs', diff --git a/packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/custom.ts b/packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/custom.ts index 4217a3c..39b39eb 100644 --- a/packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/custom.ts +++ b/packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/custom.ts @@ -1,7 +1,7 @@ import {TSESLint} from '@typescript-eslint/utils'; -import {NoMomentJsRuleName} from '../../../rules/no-moment-js'; -import {NoOnEventAssignName} from '../../../rules/no-on-event-assign'; +import {NoMomentJsRuleName} from '../../../rules/typescript/no-moment-js'; +import {NoOnEventAssignName} from '../../../rules/typescript/no-on-event-assign'; const pluginPrefix = '@cloudflight/typescript'; diff --git a/packages/eslint-plugin-typescript/src/index.ts b/packages/eslint-plugin-typescript/src/index.ts index 3fae814..b3accab 100644 --- a/packages/eslint-plugin-typescript/src/index.ts +++ b/packages/eslint-plugin-typescript/src/index.ts @@ -2,11 +2,16 @@ import pluginJs from '@eslint/js'; import tseslint from 'typescript-eslint'; import {eslintRules} from './configs/recommended-typescript/rules/eslint'; import {typescriptEslintRules} from './configs/recommended-typescript/rules/typescript-eslint'; +import {customRules} from './configs/recommended-typescript/rules/custom'; +import {cloudflightTypescriptPlugin} from './rules'; export const config = tseslint.config( { files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], ignores: ['jest.config*.ts'], + plugins: { + '@cloudflight/typescript': cloudflightTypescriptPlugin, + }, extends: [ pluginJs.configs.recommended, ...tseslint.configs.recommendedTypeChecked, @@ -14,6 +19,7 @@ export const config = tseslint.config( rules: { ...eslintRules, ...typescriptEslintRules, + ...customRules, } }, { diff --git a/packages/eslint-plugin-typescript/src/rules/index.ts b/packages/eslint-plugin-typescript/src/rules/index.ts index 2eb27b0..c5af90d 100644 --- a/packages/eslint-plugin-typescript/src/rules/index.ts +++ b/packages/eslint-plugin-typescript/src/rules/index.ts @@ -1,65 +1,34 @@ import {TSESLint} from '@typescript-eslint/utils'; +import {NoMomentJsRule, NoMomentJsRuleName} from './typescript/no-moment-js'; +import {NoOnEventAssign, NoOnEventAssignName} from './typescript/no-on-event-assign'; -import { - PackageForceAbsoluteVersionDependenciesRule, - PackageForceAbsoluteVersionDependenciesRuleName, -} from './package/package-force-absolute-version-dependencies.rule'; -import {PackageForcePrivateRule, PackageForcePrivateRuleName} from './package/package-force-private.rule'; -import { - TscAllowUnreachableCodeRule, - TscAllowUnreachableCodeRuleName, -} from './ts-config/tsc-allow-unreachable-code.rule'; -import {TscAllowUnusedLabelsRule, TscAllowUnusedLabelsRuleName} from './ts-config/tsc-allow-unused-labels.rule'; -import {TscEsModuleInteropRule, TscEsModuleInteropRuleName} from './ts-config/tsc-es-module-interop.rule'; -import { - TscForceConsistentCasingInFileNamesRule, - TscForceConsistentCasingInFileNamesRuleName, -} from './ts-config/tsc-force-consistent-casing-in-file-names.rule'; -import {TscImportHelpersRule, TscImportHelpersRuleName} from './ts-config/tsc-import-helpers.rule'; -import { - TscImportsNotUsedAsValuesRule, - TscImportsNotUsedAsValuesRuleName, -} from './ts-config/tsc-imports-not-used-as-values.rule'; -import {TscIsolatedModulesRule, TscIsolatedModulesRuleName} from './ts-config/tsc-isolated-modules.rule'; -import { - TscNoFallThroughCasesInSwitchRule, - TscNoFallThroughCasesInSwitchRuleName, -} from './ts-config/tsc-no-fall-through-cases-in-switch.rule'; -import {TscNoImplicitOverrideRule, TscNoImplicitOverrideRuleName} from './ts-config/tsc-no-implicit-override.rule'; -import {TscNoImplicitReturnsRule, TscNoImplicitReturnsRuleName} from './ts-config/tsc-no-implicit-returns.rule'; -import { - TscNoPropertyAccessFromIndexSignatureRule, - TscNoPropertyAccessFromIndexSignatureRuleName, -} from './ts-config/tsc-no-property-access-from-index-signature.rule'; -import { - TscNoUncheckedIndexedAccessRule, - TscNoUncheckedIndexedAccessRuleName, -} from './ts-config/tsc-no-unchecked-indexed-access.rule'; -import {TscStrictRule, TscStrictRuleName} from './ts-config/tsc-strict.rule'; -import { - TscUseDefineForClassFieldsRule, - TscUseDefineForClassFieldsRuleName, -} from './ts-config/tsc-use-define-for-class-fields.rule'; -import {NoMomentJsRule, NoMomentJsRuleName} from './no-moment-js'; -import {NoOnEventAssign, NoOnEventAssignName} from './no-on-event-assign'; - -export const rules: Record> = { - [PackageForcePrivateRuleName]: PackageForcePrivateRule, - [PackageForceAbsoluteVersionDependenciesRuleName]: PackageForceAbsoluteVersionDependenciesRule, - [TscAllowUnreachableCodeRuleName]: TscAllowUnreachableCodeRule, - [TscAllowUnusedLabelsRuleName]: TscAllowUnusedLabelsRule, - [TscEsModuleInteropRuleName]: TscEsModuleInteropRule, - [TscForceConsistentCasingInFileNamesRuleName]: TscForceConsistentCasingInFileNamesRule, - [TscImportHelpersRuleName]: TscImportHelpersRule, - [TscImportsNotUsedAsValuesRuleName]: TscImportsNotUsedAsValuesRule, - [TscIsolatedModulesRuleName]: TscIsolatedModulesRule, - [TscNoFallThroughCasesInSwitchRuleName]: TscNoFallThroughCasesInSwitchRule, - [TscNoImplicitOverrideRuleName]: TscNoImplicitOverrideRule, - [TscNoImplicitReturnsRuleName]: TscNoImplicitReturnsRule, - [TscNoPropertyAccessFromIndexSignatureRuleName]: TscNoPropertyAccessFromIndexSignatureRule, - [TscNoUncheckedIndexedAccessRuleName]: TscNoUncheckedIndexedAccessRule, - [TscStrictRuleName]: TscStrictRule, - [TscUseDefineForClassFieldsRuleName]: TscUseDefineForClassFieldsRule, +const rules: Record> = { + // todo: eslint-plugin-json-es is not compatible with eslint v9 as of writing + // and will be migrated later + // [PackageForcePrivateRuleName]: PackageForcePrivateRule, + // [PackageForceAbsoluteVersionDependenciesRuleName]: PackageForceAbsoluteVersionDependenciesRule, + // [TscAllowUnreachableCodeRuleName]: TscAllowUnreachableCodeRule, + // [TscAllowUnusedLabelsRuleName]: TscAllowUnusedLabelsRule, + // [TscEsModuleInteropRuleName]: TscEsModuleInteropRule, + // [TscForceConsistentCasingInFileNamesRuleName]: TscForceConsistentCasingInFileNamesRule, + // [TscImportHelpersRuleName]: TscImportHelpersRule, + // [TscImportsNotUsedAsValuesRuleName]: TscImportsNotUsedAsValuesRule, + // [TscIsolatedModulesRuleName]: TscIsolatedModulesRule, + // [TscNoFallThroughCasesInSwitchRuleName]: TscNoFallThroughCasesInSwitchRule, + // [TscNoImplicitOverrideRuleName]: TscNoImplicitOverrideRule, + // [TscNoImplicitReturnsRuleName]: TscNoImplicitReturnsRule, + // [TscNoPropertyAccessFromIndexSignatureRuleName]: TscNoPropertyAccessFromIndexSignatureRule, + // [TscNoUncheckedIndexedAccessRuleName]: TscNoUncheckedIndexedAccessRule, + // [TscStrictRuleName]: TscStrictRule, + // [TscUseDefineForClassFieldsRuleName]: TscUseDefineForClassFieldsRule, [NoMomentJsRuleName]: NoMomentJsRule, [NoOnEventAssignName]: NoOnEventAssign, }; + +export const cloudflightTypescriptPlugin: TSESLint.FlatConfig.Plugin = { + meta: { + name: '@cloudflight/typescript', + version: 'see package.json file', + }, + rules, +} diff --git a/packages/eslint-plugin-typescript/src/rules/no-moment-js.spec.ts b/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.spec.ts similarity index 100% rename from packages/eslint-plugin-typescript/src/rules/no-moment-js.spec.ts rename to packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.spec.ts diff --git a/packages/eslint-plugin-typescript/src/rules/no-moment-js.ts b/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts similarity index 94% rename from packages/eslint-plugin-typescript/src/rules/no-moment-js.ts rename to packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts index d8ce677..f3444c6 100644 --- a/packages/eslint-plugin-typescript/src/rules/no-moment-js.ts +++ b/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts @@ -1,4 +1,4 @@ -import {createRule} from '../util/create-rule'; +import {createRule} from '../../util/create-rule'; export const NoMomentJsRuleName = 'no-moment-js'; /** @@ -12,7 +12,6 @@ export const NoMomentJsRule = createRule<[], 'noMomentJs'>({ fixable: 'code', docs: { description: 'Enforces that all packages have absolute versions.', - recommended: 'strict', }, schema: [], messages: { diff --git a/packages/eslint-plugin-typescript/src/rules/no-on-event-assign.spec.ts b/packages/eslint-plugin-typescript/src/rules/typescript/no-on-event-assign.spec.ts similarity index 100% rename from packages/eslint-plugin-typescript/src/rules/no-on-event-assign.spec.ts rename to packages/eslint-plugin-typescript/src/rules/typescript/no-on-event-assign.spec.ts diff --git a/packages/eslint-plugin-typescript/src/rules/no-on-event-assign.ts b/packages/eslint-plugin-typescript/src/rules/typescript/no-on-event-assign.ts similarity index 97% rename from packages/eslint-plugin-typescript/src/rules/no-on-event-assign.ts rename to packages/eslint-plugin-typescript/src/rules/typescript/no-on-event-assign.ts index 6938dd4..391ac01 100644 --- a/packages/eslint-plugin-typescript/src/rules/no-on-event-assign.ts +++ b/packages/eslint-plugin-typescript/src/rules/typescript/no-on-event-assign.ts @@ -1,4 +1,4 @@ -import {createRule} from '../util/create-rule'; +import {createRule} from '../../util/create-rule'; const disallowedEvents = [ 'onabort', @@ -106,7 +106,6 @@ export const NoOnEventAssign = createRule<[], 'noAssign'>({ fixable: 'code', docs: { description: 'Enforces that all packages have absolute versions.', - recommended: 'strict', }, schema: [], messages: {