Skip to content

Commit 5ccd0c5

Browse files
authored
feat: Disable the no-unpublished-x rules in private packages (#57)
Private packages are never published so the `no-unpublished-import` and `no-unpublished-require` rules don't need to run. This also removes `"private": true` from most fixtures that would fail due to the rules no longer running. More information about private packages: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#private
1 parent 3e273ed commit 5ccd0c5

File tree

46 files changed

+44
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+44
-53
lines changed

lib/util/check-publish.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ exports.checkPublish = function checkPublish(context, filePath, targets) {
2626
return
2727
}
2828

29+
// Private packages are never published so we don't need to check the imported dependencies either.
30+
// More information: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#private
31+
if (packageInfo.private === true) {
32+
return
33+
}
34+
2935
const allowed = new Set(getAllowModules(context))
3036
const convertPath = getConvertPath(context)
3137
const basedir = path.dirname(packageInfo.filePath)

tests/fixtures/no-extraneous/dependencies/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "0.0.0",
54
"dependencies": {

tests/fixtures/no-extraneous/devDependencies/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "0.0.0",
54
"devDependencies": {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "0.0.0"
54
}

tests/fixtures/no-extraneous/optionalDependencies/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "0.0.0",
54
"optionalDependencies": {

tests/fixtures/no-extraneous/peerDependencies/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "0.0.0",
54
"peerDependencies": {
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "1.0.0",
5-
"bin": {"a": "lib/a.js"},
6-
"files": ["lib/a.js"]
4+
"bin": {
5+
"a": "lib/a.js"
6+
},
7+
"files": [
8+
"lib/a.js"
9+
]
710
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "1.0.0",
54
"bin": {
@@ -9,4 +8,4 @@
98
"files": [
109
"lib"
1110
]
12-
}
11+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "1.0.0",
54
"bin": {
65
"a": "a.js",
76
"b": "b.js"
87
}
9-
}
8+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"private": true,
32
"name": "test",
43
"version": "1.0.0",
54
"bin": "a.js",
65
"files": [
76
"lib"
87
]
9-
}
8+
}

0 commit comments

Comments
 (0)