eslint-plugin-n 17.8.0 → 17.9.0

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.
@@ -50,7 +50,7 @@ function isNodeShebang(shebang, executableName) {
50
50
  * @returns {string}
51
51
  */
52
52
  function getExpectedExecutableName(context) {
53
- const extension = path.extname(context.filename)
53
+ const extension = path.extname(context.filename ?? context.getFilename())
54
54
  /** @type {{ executableMap: Record<string, string> }} */
55
55
  const { executableMap = {} } = context.options?.[0] ?? {}
56
56
 
@@ -29,6 +29,7 @@ module.exports = {
29
29
  convertPath: getConvertPath.schema,
30
30
  resolvePaths: getResolvePaths.schema,
31
31
  ignoreTypeImport: { type: "boolean", default: false },
32
+ ignorePrivate: { type: "boolean", default: true },
32
33
  },
33
34
  additionalProperties: false,
34
35
  },
@@ -38,17 +39,15 @@ module.exports = {
38
39
  create(context) {
39
40
  const filePath = context.filename ?? context.getFilename()
40
41
  const options = context.options[0] || {}
41
- const ignoreTypeImport =
42
- options.ignoreTypeImport === void 0
43
- ? false
44
- : options.ignoreTypeImport
42
+ const ignoreTypeImport = options.ignoreTypeImport ?? false
43
+ const ignorePrivate = options.ignorePrivate ?? true
45
44
 
46
45
  if (filePath === "<input>") {
47
46
  return {}
48
47
  }
49
48
 
50
49
  return visitImport(context, { ignoreTypeImport }, targets => {
51
- checkPublish(context, filePath, targets)
50
+ checkPublish(context, filePath, targets, { ignorePrivate })
52
51
  })
53
52
  },
54
53
  }
@@ -30,6 +30,7 @@ module.exports = {
30
30
  convertPath: getConvertPath.schema,
31
31
  resolvePaths: getResolvePaths.schema,
32
32
  tryExtensions: getTryExtensions.schema,
33
+ ignorePrivate: { type: "boolean", default: true },
33
34
  },
34
35
  additionalProperties: false,
35
36
  },
@@ -38,12 +39,15 @@ module.exports = {
38
39
  },
39
40
  create(context) {
40
41
  const filePath = context.filename ?? context.getFilename()
42
+ const options = context.options[0] || {}
43
+ const ignorePrivate = options.ignorePrivate ?? true
44
+
41
45
  if (filePath === "<input>") {
42
46
  return {}
43
47
  }
44
48
 
45
49
  return visitRequire(context, {}, targets => {
46
- checkPublish(context, filePath, targets)
50
+ checkPublish(context, filePath, targets, { ignorePrivate })
47
51
  })
48
52
  },
49
53
  }
@@ -18,17 +18,25 @@ const { getPackageJson } = require("./get-package-json")
18
18
  * @param {import('eslint').Rule.RuleContext} context - A context to report.
19
19
  * @param {string} filePath - The current file path.
20
20
  * @param {import('./import-target.js')[]} targets - A list of target information to check.
21
+ * @param {{ignorePrivate: boolean}} options - Configuration options for checking for published files.
21
22
  * @returns {void}
22
23
  */
23
- exports.checkPublish = function checkPublish(context, filePath, targets) {
24
+ exports.checkPublish = function checkPublish(
25
+ context,
26
+ filePath,
27
+ targets,
28
+ options
29
+ ) {
24
30
  const packageJson = getPackageJson(filePath)
25
31
  if (typeof packageJson?.filePath !== "string") {
26
32
  return
27
33
  }
28
34
 
29
- // Private packages are never published so we don't need to check the imported dependencies either.
35
+ // Flag to ignore checking imported dependencies in private packages.
36
+ // For projects that need to be deployed to a server checking for imported dependencies may still be desireable
37
+ // while making it a private package.
30
38
  // More information: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#private
31
- if (packageJson.private === true) {
39
+ if (options.ignorePrivate && packageJson.private === true) {
32
40
  return
33
41
  }
34
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-n",
3
- "version": "17.8.0",
3
+ "version": "17.9.0",
4
4
  "description": "Additional ESLint's rules for Node.js",
5
5
  "engines": {
6
6
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"