Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
}
},
"dependencies": {
"@package-json/types": "^0.0.12",
"@typescript-eslint/types": "^8.56.0",
"comment-parser": "^1.4.1",
"debug": "^4.4.1",
Expand Down
3 changes: 1 addition & 2 deletions src/rules/no-duplicates.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { PackageJson } from '@package-json/types'
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
import * as semver from 'semver'

import { cjsRequire } from '../require.js'
import type { RuleContext } from '../types.js'
import type { PackageJson, RuleContext } from '../types.js'
import { createRule, lazy, resolve } from '../utils/index.js'

// a user might set prefer-inline but not have a supporting TypeScript version. Flow does not support inline types so this should fail in that case as well.
Expand Down
6 changes: 2 additions & 4 deletions src/rules/no-extraneous-dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import fs from 'node:fs'
import path from 'node:path'

import type { PackageJson } from '@package-json/types'
import type { TSESTree } from '@typescript-eslint/utils'
import { minimatch } from 'minimatch'

import type { RuleContext } from '../types.js'
import type { PackageJson, RuleContext } from '../types.js'
import {
createRule,
moduleVisitor,
Expand Down Expand Up @@ -46,8 +45,7 @@ function extractDepFields(pkg: PackageJson) {
devDependencies: pkg.devDependencies || {},
optionalDependencies: pkg.optionalDependencies || {},
peerDependencies: pkg.peerDependencies || {},
// BundledDeps should be in the form of an array, but object notation is also supported by
// `npm`, so we convert it to an array if it is an object
// bundleDependencies is an array per npm spec; this rule also accepts an object form for backward compatibility, which is not part of the npm spec
bundledDependencies: arrayOrKeys(
pkg.bundleDependencies || pkg.bundledDependencies || [],
),
Expand Down
20 changes: 20 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,23 @@ export interface NormalizedCacheSettings
extends NonNullable<ImportSettings['cache']> {
lifetime: number
}

/**
* Minimal subset of package.json fields used by this plugin.
* Defined inline to avoid a runtime dependency solely for type information.
*/
export interface PackageJson {
name?: string
version?: string
private?: boolean
main?: string
bin?: string | Record<string, string>
browser?: string | Record<string, string | false>
dependencies?: Record<string, string>
devDependencies?: Record<string, string>
optionalDependencies?: Record<string, string>
peerDependencies?: Record<string, string>
/** Array form per npm spec; object form is non-standard but intentionally supported by this rule */
bundleDependencies?: string[] | Record<string, string>
bundledDependencies?: string[] | Record<string, string>
}
2 changes: 1 addition & 1 deletion src/utils/read-pkg-up.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'

import type { PackageJson } from '@package-json/types'
import type { PackageJson } from '../types.js'

import { pkgUp } from './pkg-up.js'

Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3224,13 +3224,6 @@ __metadata:
languageName: node
linkType: hard

"@package-json/types@npm:^0.0.12":
version: 0.0.12
resolution: "@package-json/types@npm:0.0.12"
checksum: 10c0/d9bba086efe7b9901f02f1cff7a68ab23269aeddfb7ee92a16930e219f705bfc188b9fec2dd47265033dbda45ed1514d8a46f46363f38f1ad56bc993754126da
languageName: node
linkType: hard

"@pkgjs/parseargs@npm:^0.11.0":
version: 0.11.0
resolution: "@pkgjs/parseargs@npm:0.11.0"
Expand Down Expand Up @@ -6073,7 +6066,6 @@ __metadata:
"@commitlint/cli": "npm:^19.8.1"
"@eslint/import-test-order-redirect-scoped": "link:./test/fixtures/order-redirect-scoped"
"@eslint/js": "npm:^9.29.0"
"@package-json/types": "npm:^0.0.12"
"@swc-node/jest": "npm:^1.8.13"
"@swc/core": "npm:^1.12.7"
"@swc/helpers": "npm:^0.5.17"
Expand Down
Loading