npq 3.11.2 → 3.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/npq-hero.js CHANGED
@@ -71,7 +71,6 @@ marshall
71
71
  })
72
72
  .then((result) => {
73
73
  if (result && result.countErrors > 0) {
74
- // eslint-disable-next-line no-console
75
74
  console.log()
76
75
  return cliPrompt.prompt({
77
76
  name: 'install',
@@ -80,7 +79,6 @@ marshall
80
79
  })
81
80
  } else {
82
81
  if (result && result.countWarnings > 0) {
83
- // eslint-disable-next-line no-console
84
82
  console.log()
85
83
  return cliPrompt.autoContinue({
86
84
  name: 'install',
@@ -93,7 +91,11 @@ marshall
93
91
  return { install: true }
94
92
  })
95
93
  .then((status) => {
96
- if (status && status.hasOwnProperty('install') && status.install === true) {
94
+ if (
95
+ status &&
96
+ Object.prototype.hasOwnProperty.call(status, 'install') &&
97
+ status.install === true
98
+ ) {
97
99
  pkgMgr.process(PACKAGE_MANAGER_TOOL)
98
100
  }
99
101
  })
package/bin/npq.js CHANGED
@@ -97,7 +97,6 @@ Promise.resolve()
97
97
  }
98
98
 
99
99
  if (result && result.countErrors > 0) {
100
- // eslint-disable-next-line no-console
101
100
  console.log()
102
101
  return cliPrompt.prompt({
103
102
  name: 'install',
@@ -106,7 +105,6 @@ Promise.resolve()
106
105
  })
107
106
  } else {
108
107
  if (result && result.countWarnings > 0) {
109
- // eslint-disable-next-line no-console
110
108
  console.log()
111
109
  return cliPrompt.autoContinue({
112
110
  name: 'install',
@@ -119,7 +117,11 @@ Promise.resolve()
119
117
  return { install: true }
120
118
  })
121
119
  .then((status) => {
122
- if (status && status.hasOwnProperty('install') && status.install === true) {
120
+ if (
121
+ status &&
122
+ Object.prototype.hasOwnProperty.call(status, 'install') &&
123
+ status.install === true
124
+ ) {
123
125
  pkgMgr.process(cliArgs.packageManager)
124
126
  }
125
127
  })
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const growVertical = {
2
4
  interval: 120,
3
5
  frames: ['▁', '▃', '▄', '▅', '▆', '▇', '▆', '▅', '▄', '▃']
@@ -2,7 +2,6 @@
2
2
 
3
3
  const { styleText } = require('node:util')
4
4
 
5
- // eslint-disable-next-line security/detect-child-process
6
5
  const childProcess = require('child_process')
7
6
  const semver = require('semver')
8
7
 
@@ -20,10 +19,8 @@ function isEnvSupport() {
20
19
 
21
20
  function noSupportError(failFast) {
22
21
  if (isInteractiveTerminal()) {
23
- // eslint-disable-next-line no-console
24
22
  console.error(styleText('red', 'error:'), 'npq suppressed due to old node version')
25
23
  } else {
26
- // eslint-disable-next-line no-console
27
24
  console.error('error: npq suppressed due to old node version')
28
25
  }
29
26
 
@@ -85,7 +85,7 @@ class PackageRepoUtils {
85
85
  if (satisfyingVersion) {
86
86
  return satisfyingVersion
87
87
  }
88
- } catch (error) {
88
+ } catch {
89
89
  // semver.maxSatisfying throws if the range is invalid, continue to error below
90
90
  }
91
91
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  // Example use-case
2
4
  //
3
5
  // Using the new throttling mechanism - each audit will be throttled globally
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { styleText } = require('node:util')
2
4
  const { marshallCategories } = require('../marshalls/constants')
3
5
  const { isInteractiveTerminal } = require('./cliSupportHandler')
@@ -12,7 +14,7 @@ function getTerminalWidth() {
12
14
  const [columns] = process.stdout.getWindowSize()
13
15
  return columns
14
16
  }
15
- } catch (error) {
17
+ } catch {
16
18
  // Fallback if terminal size detection fails
17
19
  }
18
20
  return 80 // Default fallback width
@@ -25,6 +27,7 @@ function getTerminalWidth() {
25
27
  */
26
28
  function getDisplayLength(str) {
27
29
  // Remove ANSI escape sequences to get actual character count
30
+ // eslint-disable-next-line no-control-regex
28
31
  return str.replace(/\u001b\[[0-9;]*m/g, '').length
29
32
  }
30
33
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const path = require('node:path')
2
4
  const fs = require('node:fs/promises')
3
5
 
package/lib/marshall.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-console */
2
1
  'use strict'
3
2
 
4
3
  // const util = require('node:util')
@@ -21,7 +21,6 @@ class Marshall extends BaseMarshall {
21
21
 
22
22
  validate(pkg) {
23
23
  let packageData = null
24
- let ageDateDiff = null
25
24
  return this.packageRepoUtils
26
25
  .getPackageInfo(pkg.packageName)
27
26
  .then((data) => {
@@ -30,7 +29,6 @@ class Marshall extends BaseMarshall {
30
29
  const pkgCreatedDate = data.time.created
31
30
  const dateDiff = Date.now() - Date.parse(pkgCreatedDate)
32
31
 
33
- ageDateDiff = dateDiff
34
32
  if (dateDiff < PACKAGE_AGE_THRESHOLD) {
35
33
  throw new Error(
36
34
  `Detected a newly published package (created < ${PACKAGE_AGE_THRESHOLD} days) act carefully`
@@ -48,7 +48,7 @@ class Marshall extends BaseMarshall {
48
48
 
49
49
  // Agree with Colin on keeping email regex simple: https://colinhacks.com/essays/reasonable-email-regex
50
50
  const emailRegex =
51
- /^(?!\.)(?!.*\.\.)([a-z0-9_'+\-\.]*)[a-z0-9_'+\-]@([a-z0-9][a-z0-9\-]*\.)+[a-z]{2,}$/i
51
+ /^(?!\.)(?!.*\.\.)([a-z0-9_'+\-.]*)[a-z0-9_'+-]@([a-z0-9][a-z0-9-]*\.)+[a-z]{2,}$/i
52
52
  if (!emailRegex.test(npmUser.email)) {
53
53
  throw new Error('The publishing user has no valid email address')
54
54
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const marshallCategories = {
2
4
  SupplyChainSecurity: {
3
5
  id: 'SupplyChainSecurity',
@@ -24,7 +24,6 @@ class Marshalls {
24
24
  }
25
25
 
26
26
  const marshallTasks = marshalls.reduce((prev, curr) => {
27
- // eslint-disable-next-line security/detect-non-literal-require
28
27
  const Marshall = require(curr)
29
28
  const marshall = new Marshall(config)
30
29
 
@@ -55,7 +55,9 @@ class NewBinMarshall extends BaseMarshall {
55
55
  previousVersionData.name || pkg.packageName
56
56
  )
57
57
 
58
- const newBinaries = Object.keys(newBin).filter((key) => !oldBin.hasOwnProperty(key))
58
+ const newBinaries = Object.keys(newBin).filter(
59
+ (key) => !Object.prototype.hasOwnProperty.call(oldBin, key)
60
+ )
59
61
 
60
62
  if (newBinaries.length > 0) {
61
63
  newBinaries.forEach((binaryName) => {
@@ -188,7 +188,6 @@ class Marshall extends BaseMarshall {
188
188
  const registryKeysEndpoint = '/-/npm/v1/keys'
189
189
 
190
190
  const registryKeysUrl = `${registryHost}${registryKeysEndpoint}`
191
- // eslint-disable-next-line no-undef
192
191
  return fetch(registryKeysUrl)
193
192
  .then((response) => {
194
193
  return response.json()
@@ -30,7 +30,7 @@ class Marshall extends BaseMarshall {
30
30
  try {
31
31
  urlStructure = new URL(lastVersionData.repository.url)
32
32
  urlOfGitRepository = new URL(`https://${urlStructure.host}${urlStructure.pathname}`)
33
- } catch (error) {
33
+ } catch {
34
34
  throw new Warning('No valid repository is associated with the package')
35
35
  }
36
36
  return fetch(urlOfGitRepository.href).catch(() => {
@@ -39,7 +39,7 @@ class Marshall extends BaseMarshall {
39
39
  blacklistScripts.forEach((scriptName) => {
40
40
  if (
41
41
  packageScripts &&
42
- packageScripts.hasOwnProperty(scriptName) &&
42
+ Object.prototype.hasOwnProperty.call(packageScripts, scriptName) &&
43
43
  packageScripts[scriptName].length > 0
44
44
  ) {
45
45
  throw new Error(
@@ -63,7 +63,6 @@ class Marshall extends BaseMarshall {
63
63
  const registryKeysEndpoint = '/-/npm/v1/keys'
64
64
 
65
65
  const registryKeysUrl = `${registryHost}${registryKeysEndpoint}`
66
- // eslint-disable-next-line no-undef
67
66
  return fetch(registryKeysUrl)
68
67
  .then((response) => {
69
68
  return response.json()
@@ -163,7 +163,7 @@ class Marshall extends BaseMarshall {
163
163
  return snykConfig.api
164
164
  }
165
165
  }
166
- } catch (error) {
166
+ } catch {
167
167
  return null
168
168
  }
169
169
 
@@ -23,7 +23,6 @@ class Marshall extends BaseMarshall {
23
23
  validate(pkg) {
24
24
  let levenshteinDistance = null
25
25
  let similarPackages = []
26
- let packageFoundInTopPackages = false
27
26
  return new Promise((resolve, reject) => {
28
27
  // If package is within an allow-list
29
28
  if (this.packageRepoUtils.isPackageInAllowList(pkg.packageName)) {
@@ -34,7 +33,6 @@ class Marshall extends BaseMarshall {
34
33
  // If the package to be installed is itself found within the Top Packages dataset
35
34
  // then we don't report on it
36
35
  if (pkg.packageName === popularPackageNameInRepository) {
37
- packageFoundInTopPackages = true
38
36
  return resolve([])
39
37
  }
40
38
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable indent */
2
1
  'use strict'
3
2
 
4
3
  const childProcess = require('child_process')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npq",
3
- "version": "3.11.2",
3
+ "version": "3.11.3",
4
4
  "description": "marshall your npm/npm package installs with high quality and class 🎖",
5
5
  "bin": {
6
6
  "npq": "./bin/npq.js",
@@ -9,19 +9,16 @@
9
9
  "scripts": {
10
10
  "lint": "eslint && npm run lint:lockfile",
11
11
  "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --validate-https --allowed-hosts npm npm",
12
- "test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest",
12
+ "fix": "eslint --fix",
13
+ "test": "jest",
13
14
  "build": "node scripts/build.js",
14
- "test:watch": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --watch",
15
- "coverage:view": "opn coverage/lcov-report/index.html",
15
+ "test:watch": "jest --watch",
16
16
  "commit": "git-cz",
17
17
  "format": "prettier --config .prettierrc.js --write \"**/*.js\"",
18
- "docs": "npm run docs:code && npm run docs:api",
19
- "docs:api": "doxdox \"*.js\" --layout bootstrap --output docs/index.html",
20
- "docs:code": "docco \"*.js\" --output docs/code",
21
18
  "semantic-release": "npx semantic-release",
22
19
  "#postinstall": "node scripts/postinstall.js",
23
20
  "#preuninstall": "node scripts/preuninstall.js",
24
- "#prepare": "husky install"
21
+ "prepare": "husky || true"
25
22
  },
26
23
  "engines": {
27
24
  "node": ">=20.13.0"
@@ -52,59 +49,21 @@
52
49
  "semver": "^7.7.2"
53
50
  },
54
51
  "devDependencies": {
55
- "@babel/core": "^7.28.0",
56
- "@babel/plugin-transform-runtime": "^7.28.0",
57
- "@babel/preset-env": "^7.28.0",
58
- "@babel/runtime": "^7.28.2",
59
- "@babel/types": "^7.28.2",
60
52
  "@commitlint/cli": "^19.8.1",
61
53
  "@commitlint/config-angular": "^19.8.1",
54
+ "@eslint/js": "^9.32.0",
62
55
  "commitizen": "^4.3.1",
63
- "cross-env": "^10.0.0",
64
56
  "cz-conventional-changelog": "^3.3.0",
65
57
  "eslint": "^9.32.0",
66
- "eslint-plugin-import": "^2.32.0",
58
+ "eslint-plugin-n": "^17.21.3",
67
59
  "eslint-plugin-security": "^3.0.1",
60
+ "globals": "^16.3.0",
68
61
  "husky": "^9.1.7",
69
62
  "jest": "^30.0.5",
70
63
  "lint-staged": "^16.1.4",
71
64
  "lockfile-lint": "^4.14.1",
72
65
  "prettier": "^3.6.2"
73
66
  },
74
- "jest": {
75
- "testEnvironment": "node",
76
- "verbose": true,
77
- "notify": false,
78
- "collectCoverage": true,
79
- "coverageThreshold": {
80
- "global": {
81
- "branches": 75,
82
- "functions": 75,
83
- "lines": 75,
84
- "statements": 75
85
- },
86
- "scripts/*": {
87
- "branches": 60,
88
- "functions": 90,
89
- "lines": 80,
90
- "statements": 80
91
- }
92
- },
93
- "testMatch": [
94
- "**/__tests__/**/*.test.js"
95
- ],
96
- "testPathIgnorePatterns": [
97
- "/__tests__/__fixtures__/*"
98
- ]
99
- },
100
- "babel": {
101
- "presets": [
102
- "@babel/env"
103
- ],
104
- "plugins": [
105
- "@babel/plugin-transform-runtime"
106
- ]
107
- },
108
67
  "config": {
109
68
  "commitizen": {
110
69
  "path": "./node_modules/cz-conventional-changelog"
@@ -118,72 +77,9 @@
118
77
  "lint-staged": {
119
78
  "**/*.js": [
120
79
  "npm run format",
121
- "npm run lint",
122
- "git add"
80
+ "npm run lint"
123
81
  ]
124
82
  },
125
- "eslintConfig": {
126
- "env": {
127
- "node": true,
128
- "es6": true,
129
- "jest": true
130
- },
131
- "plugins": [
132
- "node",
133
- "security"
134
- ],
135
- "extends": [
136
- "plugin:node/recommended",
137
- "plugin:security/recommended"
138
- ],
139
- "rules": {
140
- "semi": "off",
141
- "no-process-exit": "off",
142
- "node/no-unsupported-features": "off",
143
- "node/no-unpublished-require": "off",
144
- "security/detect-non-literal-fs-filename": "warn",
145
- "security/detect-unsafe-regex": "warn",
146
- "security/detect-buffer-noassert": "error",
147
- "security/detect-child-process": "warn",
148
- "security/detect-disable-mustache-escape": "error",
149
- "security/detect-eval-with-expression": "error",
150
- "security/detect-no-csrf-before-method-override": "error",
151
- "security/detect-non-literal-regexp": "error",
152
- "security/detect-non-literal-require": "warn",
153
- "security/detect-object-injection": "off",
154
- "security/detect-possible-timing-attacks": "error",
155
- "security/detect-pseudoRandomBytes": "error",
156
- "node/no-unsupported-features/node-builtins": [
157
- "error",
158
- {
159
- "version": ">=18.17.0",
160
- "ignores": []
161
- }
162
- ],
163
- "node/no-unsupported-features/es-syntax": [
164
- "error",
165
- {
166
- "version": ">=18.17.0",
167
- "ignores": []
168
- }
169
- ]
170
- },
171
- "overrides": [
172
- {
173
- "files": [
174
- "__tests__/*"
175
- ],
176
- "rules": {
177
- "node/no-unsupported-features/es-syntax": "off"
178
- }
179
- }
180
- ],
181
- "parserOptions": {
182
- "ecmaFeatures": {
183
- "impliedStrict": true
184
- }
185
- }
186
- },
187
83
  "release": {
188
84
  "branches": [
189
85
  "main"
package/scripts/build.js CHANGED
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const fs = require('fs/promises')
2
4
  const path = require('path')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const fs = require('fs')
2
4
  const { styleText } = require('node:util')
3
5
  const semver = require('semver')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const helpers = require('./scriptHelpers')
2
4
 
3
5
  const runPreUninstall = async () => {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const fs = require('fs')
2
4
  const os = require('os')
3
5
  const path = require('path')