Skip to content

Commit

Permalink
test: no import sub-dep @typescript-eslint/eslint-plugin
Browse files Browse the repository at this point in the history
Co-authored-by: Rostislav Simonik <[email protected]>
  • Loading branch information
mightyiam and rostislav-simonik committed Jun 15, 2024
1 parent 8cf75f4 commit de9b499
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/test/equivalents.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import test from 'ava'
import { rules as tseslintRules } from '@typescript-eslint/eslint-plugin'
import { plugin } from 'typescript-eslint'
import { equivalents, ourRules } from './_util'
import { type TSESLint } from '@typescript-eslint/utils'

test('JS equivalent rules are off', async (t) => {
if (plugin.rules === undefined) throw new Error()
const ourRules_: TSESLint.FlatConfig.Rules = ourRules
Object.keys(ourRules_).forEach((name) => {
const bareName = name.replace('@typescript-eslint/', '')
if (!Object.prototype.hasOwnProperty.call(tseslintRules, bareName)) return
if (!Object.prototype.hasOwnProperty.call(plugin.rules, bareName)) return
if (!equivalents.includes(bareName)) return
const config = ourRules_[bareName]
t.deepEqual(config, ['off'], bareName)
Expand Down
4 changes: 3 additions & 1 deletion src/test/rules-to-consider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava'
import pluginTseslint from '@typescript-eslint/eslint-plugin'
import { plugin as pluginTseslint } from 'typescript-eslint'
import * as pluginN from 'eslint-plugin-n'
import * as pluginImport from 'eslint-plugin-import'
import * as pluginPromise from 'eslint-plugin-promise'
Expand All @@ -16,6 +16,7 @@ const eslintRules = new TSESLint.Linter().getRules()
if (pluginN.rules === undefined) throw new Error()
if (pluginImport.rules === undefined) throw new Error()
if (pluginPromise.rules === undefined) throw new Error()
if (pluginTseslint.rules === undefined) throw new Error()

const rulesets: Array<[TSESLint.Linter.Plugin, string]> = [
[pluginTseslint.rules, '@typescript-eslint'],
Expand Down Expand Up @@ -74,6 +75,7 @@ const notYetConsideredRules = [
'@typescript-eslint/no-type-alias',
'@typescript-eslint/no-unnecessary-condition',
'@typescript-eslint/no-unnecessary-qualifier',
'@typescript-eslint/no-unnecessary-template-expression',
'@typescript-eslint/no-unnecessary-type-arguments',
'@typescript-eslint/no-unsafe-assignment',
'@typescript-eslint/no-unsafe-call',
Expand Down

0 comments on commit de9b499

Please sign in to comment.