Skip to content

Commit

Permalink
Merge pull request #1523 from mightyiam/tseslint-var-name
Browse files Browse the repository at this point in the history
chore: rename some vars in tests
  • Loading branch information
mightyiam committed Apr 12, 2024
2 parents c4cd049 + 80a24c7 commit 3084685
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/test/_util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import exported from '..'
import { rules as typescriptEslintRules } from '@typescript-eslint/eslint-plugin'
import { rules as tseslintRules } from '@typescript-eslint/eslint-plugin'
import { TSESLint } from '@typescript-eslint/utils'
import semver from 'semver'
import { type PackageJson } from 'type-fest'
Expand Down Expand Up @@ -48,9 +48,9 @@ if (ourRules_ === undefined) throw new Error('we seem to be exporting no rules')
export const ourRules = ourRules_

export const equivalents = [...(new TSESLint.Linter()).getRules().keys()]
.filter(name => Object.prototype.hasOwnProperty.call(typescriptEslintRules, name))
.filter(name => Object.prototype.hasOwnProperty.call(tseslintRules, name))

export const typescriptEslintBottom = '@typescript-eslint_bottom'
export const tseslintBottom = '@typescript-eslint_bottom'

export const expectedExportedValue = {
plugins: [
Expand Down
16 changes: 8 additions & 8 deletions src/test/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import test from 'ava'
import { TSESLint } from '@typescript-eslint/utils'
import exported from '..'
import semver from 'semver'
import { extractVersionRange, getPkgDetails, ourRules, typescriptEslintBottom } from './_util'
import { extractVersionRange, getPkgDetails, ourRules, tseslintBottom } from './_util'

const typescriptEslintBottomPlugin = `${typescriptEslintBottom}/eslint-plugin`
const typescriptEslintBottomParser = `${typescriptEslintBottom}/parser`
const tseslintBottomPlugin = `${tseslintBottom}/eslint-plugin`
const tseslintBottomParser = `${tseslintBottom}/parser`

test('our configuration is compatible with the plugin and parser at bottom of peer dep range', async (t) => {
const { ourPeerDeps, ourDevDeps } = await getPkgDetails()

const peerDepRange = ourPeerDeps['@typescript-eslint/eslint-plugin']
if (peerDepRange === undefined) throw new Error()

const bottomPluginRange = ourDevDeps[typescriptEslintBottomPlugin]
const bottomPluginRange = ourDevDeps[tseslintBottomPlugin]
if (bottomPluginRange === undefined) throw new Error()
const bottomPluginVersion = extractVersionRange(bottomPluginRange)
const bottomParserRange = ourDevDeps[typescriptEslintBottomParser]
const bottomParserRange = ourDevDeps[tseslintBottomParser]
if (bottomParserRange === undefined) throw new Error()
const bottomParserVersion = extractVersionRange(bottomParserRange)

Expand All @@ -30,12 +30,12 @@ test('our configuration is compatible with the plugin and parser at bottom of pe
...structuredClone(exported),
plugins: [
...exported.plugins.filter(p => p !== '@typescript-eslint'),
typescriptEslintBottomPlugin
tseslintBottomPlugin
],
parser: typescriptEslintBottomParser,
parser: tseslintBottomParser,
rules: Object.fromEntries(
Object.entries(ourRules).map(([name, config]) => [
name.replace('@typescript-eslint/', `${typescriptEslintBottom}/`),
name.replace('@typescript-eslint/', `${tseslintBottom}/`),
config
])
),
Expand Down
4 changes: 2 additions & 2 deletions src/test/equivalents.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import test from 'ava'
import { rules as typescriptEslintRules } from '@typescript-eslint/eslint-plugin'
import { rules as tseslintRules } from '@typescript-eslint/eslint-plugin'
import { equivalents, ourRules } from './_util'

test('JS equivalent rules are off', async (t) => {
Object.keys(ourRules).forEach((name) => {
const bareName = name.replace('@typescript-eslint/', '')
if (!Object.prototype.hasOwnProperty.call(typescriptEslintRules, bareName)) return
if (!Object.prototype.hasOwnProperty.call(tseslintRules, bareName)) return
if (!equivalents.includes(bareName)) return
const config = ourRules[bareName]
t.deepEqual(config, ['off'], bareName)
Expand Down

0 comments on commit 3084685

Please sign in to comment.