Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: eslint-community/eslint-plugin-n
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 16.2.0
Choose a base ref
...
head repository: eslint-community/eslint-plugin-n
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 16.3.0
Choose a head ref
  • 7 commits
  • 47 files changed
  • 4 contributors

Commits on Oct 17, 2023

  1. Copy the full SHA
    fba650a View commit details

Commits on Oct 19, 2023

  1. Copy the full SHA
    2200c43 View commit details

Commits on Oct 20, 2023

  1. Copy the full SHA
    446e744 View commit details

Commits on Nov 1, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    79c8afd View commit details

Commits on Nov 7, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ff01930 View commit details
  2. Copy the full SHA
    22ba54c View commit details
  3. Release 16.3.0

    aladdin-add committed Nov 7, 2023
    Copy the full SHA
    5343efd View commit details
Showing with 147 additions and 51 deletions.
  1. +52 −0 .github/ISSUE_TEMPLATE/bug-report.yml
  2. +1 −0 .github/ISSUE_TEMPLATE/config.yml
  3. +41 −0 .github/ISSUE_TEMPLATE/new-rule.yml
  4. +1 −1 README.md
  5. +1 −1 docs/rules/no-callback-literal.md
  6. +0 −1 lib/rules/callback-return.js
  7. +0 −1 lib/rules/exports-style.js
  8. +6 −10 lib/rules/file-extension-in-import.js
  9. +0 −1 lib/rules/global-require.js
  10. +0 −1 lib/rules/handle-callback-err.js
  11. +0 −1 lib/rules/no-callback-literal.js
  12. +0 −1 lib/rules/no-deprecated-api.js
  13. +0 −1 lib/rules/no-exports-assign.js
  14. +0 −1 lib/rules/no-extraneous-import.js
  15. +0 −1 lib/rules/no-extraneous-require.js
  16. +0 −1 lib/rules/no-hide-core-modules.js
  17. +0 −1 lib/rules/no-missing-import.js
  18. +0 −1 lib/rules/no-missing-require.js
  19. +0 −1 lib/rules/no-mixed-requires.js
  20. +0 −1 lib/rules/no-new-require.js
  21. +0 −1 lib/rules/no-path-concat.js
  22. +0 −1 lib/rules/no-process-env.js
  23. +0 −1 lib/rules/no-process-exit.js
  24. +0 −1 lib/rules/no-restricted-import.js
  25. +0 −1 lib/rules/no-restricted-require.js
  26. +0 −1 lib/rules/no-sync.js
  27. +0 −1 lib/rules/no-unpublished-bin.js
  28. +0 −1 lib/rules/no-unpublished-import.js
  29. +0 −1 lib/rules/no-unpublished-require.js
  30. +0 −1 lib/rules/no-unsupported-features.js
  31. +0 −1 lib/rules/no-unsupported-features/es-builtins.js
  32. +0 −1 lib/rules/no-unsupported-features/es-syntax.js
  33. +0 −1 lib/rules/no-unsupported-features/node-builtins.js
  34. +0 −1 lib/rules/prefer-global/buffer.js
  35. +0 −1 lib/rules/prefer-global/console.js
  36. +0 −1 lib/rules/prefer-global/process.js
  37. +0 −1 lib/rules/prefer-global/text-decoder.js
  38. +0 −1 lib/rules/prefer-global/text-encoder.js
  39. +0 −1 lib/rules/prefer-global/url-search-params.js
  40. +0 −1 lib/rules/prefer-global/url.js
  41. +0 −1 lib/rules/prefer-promises/dns.js
  42. +0 −1 lib/rules/prefer-promises/fs.js
  43. +0 −1 lib/rules/process-exit-as-throw.js
  44. +0 −1 lib/rules/shebang.js
  45. +27 −0 lib/util/import-target.js
  46. +1 −1 package.json
  47. +17 −0 tests/lib/rules/file-extension-in-import.js
52 changes: 52 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "\U0001F41E Report a problem"
description: "Report an issue with eslint-plugin-n"
title: "Bug: (fill in)"
labels:
- bug
body:
- type: markdown
attributes:
value: By opening an issue, you agree to abide by the [Open JS Foundation Code of Conduct](https://eslint.org/conduct).
- type: textarea
attributes:
label: Environment
description: |
Please tell us about how you're running ESLint.
value: |
Node version:
npm version:
ESLint version:
eslint-plugin-n version:
Operating System:
validations:
required: true
- type: input
attributes:
label: What rule do you want to report?
description: Please provide the name of the rule you're having problems with.
validations:
required: true
- type: input
attributes:
label: Link to Minimal Reproducible Example
description: 'Link to a [playground](https://eslint-online-playground.netlify.app/), [StackBlitz](https://stackblitz.com), or GitHub repo with a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be auto-closed.'
placeholder: 'https://eslint-online-playground.netlify.app/#'
validations:
required: true
- type: textarea
attributes:
label: What did you expect to happen?
description: |
You can use Markdown in this field.
validations:
required: true
- type: checkboxes
attributes:
label: Participation
options:
- label: I am willing to submit a pull request for this issue.
required: false
- type: textarea
attributes:
label: Additional comments
description: Is there anything else that's important for the team to know?
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/new-rule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "\U0001F680 Propose a new rule"
description: "Propose a new rule to be added to the plugin"
title: "New Rule: (fill in)"
labels:
- rule
- feature
body:
- type: markdown
attributes:
value: By opening an issue, you agree to abide by the [Open JS Foundation Code of Conduct](https://eslint.org/conduct).
- type: textarea
attributes:
label: Rule details
description: What should the new rule do?
validations:
required: true
- type: dropdown
attributes:
label: What type of rule is this?
options:
- Warns about a potential problem
- Suggests an alternate way of doing something
validations:
required: true
- type: textarea
attributes:
label: Example code
description: Please provide some example JavaScript code that this rule will warn about. This field will render as JavaScript.
render: js
validations:
required: true
- type: checkboxes
attributes:
label: Participation
options:
- label: I am willing to submit a pull request to implement this rule.
required: false
- type: textarea
attributes:
label: Additional comments
description: Is there anything else that's important for the team to know?
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
[![Downloads](https://img.shields.io/npm/dm/eslint-plugin-n.svg)](https://www.npmjs.com/package/eslint-plugin-n)
[![Build Status](https://github.com/eslint-community/eslint-plugin-n/workflows/CI/badge.svg)](https://github.com/eslint-community/eslint-plugin-n/actions)

Additional ESLint's rules for Node.js
Additional ESLint rules for Node.js

## 💿 Install & Usage

2 changes: 1 addition & 1 deletion docs/rules/no-callback-literal.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ When invoking a callback function which uses the Node.js error-first callback pa

## 📖 Rule Details

When a function is named `cb` or `callback`, then it must be invoked with a first argument that is `undefined`, `null`, an `Error` class, or a subclass or `Error`.
When a function is named `cb` or `callback`, then it must be invoked with a first argument that is `undefined`, `null`, an `Error` class, or a subclass of `Error`.

Examples of 👎 **incorrect** code for this rule:

1 change: 0 additions & 1 deletion lib/rules/callback-return.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "require `return` statements after callbacks",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/callback-return.md",
},
1 change: 0 additions & 1 deletion lib/rules/exports-style.js
Original file line number Diff line number Diff line change
@@ -227,7 +227,6 @@ module.exports = {
meta: {
docs: {
description: "enforce either `module.exports` or `exports`",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/exports-style.md",
},
16 changes: 6 additions & 10 deletions lib/rules/file-extension-in-import.js
Original file line number Diff line number Diff line change
@@ -8,9 +8,6 @@ const path = require("path")
const fs = require("fs")
const mapTypescriptExtension = require("../util/map-typescript-extension")
const visitImport = require("../util/visit-import")
const packageNamePattern = /^(?:@[^/\\]+[/\\])?[^/\\]+$/u
const corePackageOverridePattern =
/^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|worker_threads|zlib)[/\\]$/u

/**
* Get all file extensions of the files which have the same basename.
@@ -37,7 +34,6 @@ module.exports = {
docs: {
description:
"enforce the style of file extensions in `import` declarations",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/file-extension-in-import.md",
},
@@ -67,13 +63,13 @@ module.exports = {
const defaultStyle = context.options[0] || "always"
const overrideStyle = context.options[1] || {}

function verify({ filePath, name, node }) {
/**
* @param {import("../util/import-target.js")} target
* @returns {void}
*/
function verify({ filePath, name, node, moduleType }) {
// Ignore if it's not resolved to a file or it's a bare module.
if (
!filePath ||
packageNamePattern.test(name) ||
corePackageOverridePattern.test(name)
) {
if (moduleType !== "relative" && moduleType !== "absolute") {
return
}

1 change: 0 additions & 1 deletion lib/rules/global-require.js
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@ module.exports = {
docs: {
description:
"require `require()` calls to be placed at top-level module scope",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/global-require.md",
},
1 change: 0 additions & 1 deletion lib/rules/handle-callback-err.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "require error handling in callbacks",
category: "Possible Errors",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/handle-callback-err.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-callback-literal.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ module.exports = {
docs: {
description:
"enforce Node.js-style error-first callback pattern is followed",
category: "Possible Errors",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-callback-literal.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-deprecated-api.js
Original file line number Diff line number Diff line change
@@ -691,7 +691,6 @@ module.exports = {
meta: {
docs: {
description: "disallow deprecated APIs",
category: "Best Practices",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-deprecated-api.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-exports-assign.js
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@ module.exports = {
meta: {
docs: {
description: "disallow the assignment to `exports`",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-exports-assign.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-extraneous-import.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ module.exports = {
docs: {
description:
"disallow `import` declarations which import extraneous modules",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-import.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-extraneous-require.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ module.exports = {
docs: {
description:
"disallow `require()` expressions which import extraneous modules",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-extraneous-require.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-hide-core-modules.js
Original file line number Diff line number Diff line change
@@ -57,7 +57,6 @@ module.exports = {
docs: {
description:
"disallow third-party modules which are hiding core modules",
category: "Possible Errors",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-hide-core-modules.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-missing-import.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ module.exports = {
docs: {
description:
"disallow `import` declarations which import non-existence modules",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-import.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-missing-require.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ module.exports = {
docs: {
description:
"disallow `require()` expressions which import non-existence modules",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-missing-require.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-mixed-requires.js
Original file line number Diff line number Diff line change
@@ -71,7 +71,6 @@ module.exports = {
docs: {
description:
"disallow `require` calls to be mixed with regular variable declarations",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-mixed-requires.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-new-require.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "disallow `new` operators with calls to `require`",
category: "Possible Errors",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-new-require.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-path-concat.js
Original file line number Diff line number Diff line change
@@ -166,7 +166,6 @@ module.exports = {
docs: {
description:
"disallow string concatenation with `__dirname` and `__filename`",
category: "Possible Errors",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-path-concat.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-process-env.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "disallow the use of `process.env`",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-env.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-process-exit.js
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "disallow the use of `process.exit()`",
category: "Possible Errors",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-exit.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-restricted-import.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ module.exports = {
docs: {
description:
"disallow specified modules when loaded by `import` declarations",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-restricted-import.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-restricted-require.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "disallow specified modules when loaded by `require`",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-restricted-require.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-sync.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ module.exports = {
type: "suggestion",
docs: {
description: "disallow synchronous methods",
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-sync.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-unpublished-bin.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ module.exports = {
meta: {
docs: {
description: "disallow `bin` files that npm ignores",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-bin.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-unpublished-import.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ module.exports = {
docs: {
description:
"disallow `import` declarations which import private modules",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-import.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-unpublished-require.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ module.exports = {
docs: {
description:
"disallow `require()` expressions which import private modules",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-require.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-unsupported-features.js
Original file line number Diff line number Diff line change
@@ -1048,7 +1048,6 @@ module.exports = {
docs: {
description:
"disallow unsupported ECMAScript features on the specified version",
category: "Possible Errors",
recommended: false,

url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features.md",
1 change: 0 additions & 1 deletion lib/rules/no-unsupported-features/es-builtins.js
Original file line number Diff line number Diff line change
@@ -143,7 +143,6 @@ module.exports = {
docs: {
description:
"disallow unsupported ECMAScript built-ins on the specified version",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/es-builtins.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-unsupported-features/es-syntax.js
Original file line number Diff line number Diff line change
@@ -523,7 +523,6 @@ module.exports = {
docs: {
description:
"disallow unsupported ECMAScript syntax on the specified version",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/es-syntax.md",
},
1 change: 0 additions & 1 deletion lib/rules/no-unsupported-features/node-builtins.js
Original file line number Diff line number Diff line change
@@ -379,7 +379,6 @@ module.exports = {
docs: {
description:
"disallow unsupported Node.js built-in APIs on the specified version",
category: "Possible Errors",
recommended: true,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unsupported-features/node-builtins.md",
},
1 change: 0 additions & 1 deletion lib/rules/prefer-global/buffer.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ module.exports = {
docs: {
description:
'enforce either `Buffer` or `require("buffer").Buffer`',
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/buffer.md",
},
1 change: 0 additions & 1 deletion lib/rules/prefer-global/console.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ module.exports = {
meta: {
docs: {
description: 'enforce either `console` or `require("console")`',
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/console.md",
},
1 change: 0 additions & 1 deletion lib/rules/prefer-global/process.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ module.exports = {
meta: {
docs: {
description: 'enforce either `process` or `require("process")`',
category: "Stylistic Issues",
recommended: false,
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-global/process.md",
},
Loading