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: 17.0.0-3
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: v17.0.0-4
Choose a head ref
  • 7 commits
  • 61 files changed
  • 4 contributors

Commits on Feb 27, 2024

  1. fix(no-unsupported-features): Remove use of static as a variable (#190

    )
    
    Thank you @alex-kinokon for spotting this!
    scagood authored Feb 27, 2024
    Copy the full SHA
    e31d868 View commit details

Commits on Feb 28, 2024

  1. chore: Enable global strict eslint rule (#191)

    * lint: Enable global strict eslint rule
    
    * chore: Add missing "use strict" directives
    
    * chore: Move strict check to everywhere
    scagood authored Feb 28, 2024
    Copy the full SHA
    99fe387 View commit details
  2. ci: Migrate to manifest config (#192)

    scagood authored Feb 28, 2024
    Copy the full SHA
    c8a87f3 View commit details

Commits on Mar 4, 2024

  1. feat: Update ES Syntax (#189)

    * chore: Add all es-x rules to es-syntax.json
    
    * chore: Add a couple of missing syntax 🤔
    
    * chore: #json comments
    
    * chore: Attempt (part 1) of simplifying es-syntax
    
    * chore: Add "test:mocha" to be able to run tests on one file faster
    
    * chore: Updates to the es-syntax.json
    
    * feat: Re-add support for strict mode
    
    * chore: Update all tests to support "not-supported-till"
    
    * fix: strip "no-" prefix from es-x rule ids
    
    * chore: remove useless comment
    
    * fix: Add the ability to have es-syntax aliases
    
    * feat: Add compat aliases for es-syntax
    
    * feat: Use "featureName" over "ruleId" in error message
    scagood authored Mar 4, 2024
    Copy the full SHA
    4778ae8 View commit details

Commits on Mar 5, 2024

  1. feat(shebang): add support for env's split-string option (#195)

    * feat(shebang): add support for env's split-string option
    
    This is useful for passing arguments to node
    
    * feat(shebang): support all `env` options
    
    * feat(shebang): improve regex performance
    dudeofawesome authored Mar 5, 2024
    Copy the full SHA
    b383b49 View commit details

Commits on Mar 6, 2024

  1. feat!: rename rule shebang => hashbang, deprecate rule shebang (#198)

    fixes #196
    aladdin-add authored Mar 6, 2024
    Copy the full SHA
    cefdb1c View commit details
  2. chore(master): release 17.0.0-4 (#176)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Mar 6, 2024
    Copy the full SHA
    b7c6409 View commit details
Showing with 2,536 additions and 1,626 deletions.
  1. +18 −0 .github/release-please/config.json
  2. +1 −0 .github/release-please/manifest.json
  3. +4 −16 .github/workflows/release-please.yml
  4. +25 −0 CHANGELOG.md
  5. +2 −1 README.md
  6. +88 −0 docs/rules/hashbang.md
  7. +2 −2 docs/rules/shebang.md
  8. +4 −1 eslint.config.js
  9. +1 −1 lib/configs/_commons.js
  10. +2 −1 lib/index.js
  11. +212 −0 lib/rules/hashbang.js
  12. +30 −0 lib/rules/no-unsupported-features/es-syntax-additions.json
  13. +106 −601 lib/rules/no-unsupported-features/es-syntax.js
  14. +615 −0 lib/rules/no-unsupported-features/es-syntax.json
  15. +9 −202 lib/rules/shebang.js
  16. +2 −0 lib/unsupported-features/node-builtins-modules/assert.js
  17. +2 −0 lib/unsupported-features/node-builtins-modules/async_hooks.js
  18. +2 −0 lib/unsupported-features/node-builtins-modules/buffer.js
  19. +2 −0 lib/unsupported-features/node-builtins-modules/child_process.js
  20. +2 −0 lib/unsupported-features/node-builtins-modules/cluster.js
  21. +2 −0 lib/unsupported-features/node-builtins-modules/console.js
  22. +2 −0 lib/unsupported-features/node-builtins-modules/crypto.js
  23. +2 −0 lib/unsupported-features/node-builtins-modules/dgram.js
  24. +2 −0 lib/unsupported-features/node-builtins-modules/diagnostics_channel.js
  25. +2 −0 lib/unsupported-features/node-builtins-modules/dns.js
  26. +2 −0 lib/unsupported-features/node-builtins-modules/domain.js
  27. +6 −4 lib/unsupported-features/node-builtins-modules/events.js
  28. +2 −0 lib/unsupported-features/node-builtins-modules/fs.js
  29. +2 −0 lib/unsupported-features/node-builtins-modules/http.js
  30. +2 −0 lib/unsupported-features/node-builtins-modules/http2.js
  31. +2 −0 lib/unsupported-features/node-builtins-modules/https.js
  32. +2 −0 lib/unsupported-features/node-builtins-modules/inspector.js
  33. +2 −0 lib/unsupported-features/node-builtins-modules/module.js
  34. +2 −0 lib/unsupported-features/node-builtins-modules/net.js
  35. +2 −0 lib/unsupported-features/node-builtins-modules/os.js
  36. +2 −0 lib/unsupported-features/node-builtins-modules/path.js
  37. +2 −0 lib/unsupported-features/node-builtins-modules/perf_hooks.js
  38. +2 −0 lib/unsupported-features/node-builtins-modules/process.js
  39. +2 −0 lib/unsupported-features/node-builtins-modules/punycode.js
  40. +2 −0 lib/unsupported-features/node-builtins-modules/querystring.js
  41. +2 −0 lib/unsupported-features/node-builtins-modules/readline.js
  42. +2 −0 lib/unsupported-features/node-builtins-modules/stream.js
  43. +2 −0 lib/unsupported-features/node-builtins-modules/string_decoder.js
  44. +2 −0 lib/unsupported-features/node-builtins-modules/test.js
  45. +2 −0 lib/unsupported-features/node-builtins-modules/timers.js
  46. +2 −0 lib/unsupported-features/node-builtins-modules/tls.js
  47. +2 −0 lib/unsupported-features/node-builtins-modules/trace_events.js
  48. +2 −0 lib/unsupported-features/node-builtins-modules/tty.js
  49. +2 −0 lib/unsupported-features/node-builtins-modules/url.js
  50. +2 −0 lib/unsupported-features/node-builtins-modules/util.js
  51. +2 −0 lib/unsupported-features/node-builtins-modules/v8.js
  52. +2 −0 lib/unsupported-features/node-builtins-modules/vm.js
  53. +2 −0 lib/unsupported-features/node-builtins-modules/wasi.js
  54. +2 −0 lib/unsupported-features/node-builtins-modules/worker_threads.js
  55. +2 −0 lib/unsupported-features/node-builtins-modules/zlib.js
  56. +2 −0 lib/unsupported-features/node-builtins.js
  57. +2 −0 lib/unsupported-features/types.js
  58. +3 −2 package.json
  59. +465 −0 tests/lib/rules/hashbang.js
  60. +854 −359 tests/lib/rules/no-unsupported-features/es-syntax.js
  61. +7 −436 tests/lib/rules/shebang.js
18 changes: 18 additions & 0 deletions .github/release-please/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"release-type": "node",
"prerelease": true,
"versioning": "prerelease",
"include-component-in-tag": false,
"changelog-sections": [
{ "type": "feat", "section": "Features", "hidden": false },
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
{ "type": "docs", "section": "Documentation", "hidden": false },
{ "type": "build", "section": "Build Related", "hidden": false },
{ "type": "chore", "section": "Chores", "hidden": false },
{ "type": "perf", "section": "Chores", "hidden": false },
{ "type": "ci", "section": "Chores", "hidden": false },
{ "type": "refactor", "section": "Chores", "hidden": false },
{ "type": "test", "section": "Chores", "hidden": false }
],
"packages": { ".": {} }
}
1 change: 1 addition & 0 deletions .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".":"17.0.0-4"}
20 changes: 4 additions & 16 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -14,21 +14,9 @@ jobs:
- uses: google-github-actions/release-please-action@v4
id: release
with:
release-type: node
prerelease: beta
package-name: 'eslint-plugin-n'
changelog-types: >
[
{ "type": "feat", "section": "Features", "hidden": false },
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
{ "type": "docs", "section": "Documentation", "hidden": false },
{ "type": "build", "section": "Build Related", "hidden": false },
{ "type": "chore", "section": "Chores", "hidden": false },
{ "type": "perf", "section": "Chores", "hidden": false },
{ "type": "ci", "section": "Chores", "hidden": false },
{ "type": "refactor", "section": "Chores", "hidden": false },
{ "type": "test", "section": "Chores", "hidden": false }
]
config-file: .github/release-please/config.json
manifest-file: .github/release-please/manifest.json

- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v4
@@ -38,7 +26,7 @@ jobs:
if: ${{ steps.release.outputs.release_created }}
- run: |
npm install
npm publish --provenance
npm publish --provenance --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

## [17.0.0-4](https://github.com/eslint-community/eslint-plugin-n/compare/17.0.0-3...v17.0.0-4) (2024-03-06)


### ⚠ BREAKING CHANGES

* rename rule shebang => hashbang, deprecate rule shebang ([#198](https://github.com/eslint-community/eslint-plugin-n/issues/198))

### Features

* rename rule shebang =&gt; hashbang, deprecate rule shebang ([#198](https://github.com/eslint-community/eslint-plugin-n/issues/198)) ([cefdb1c](https://github.com/eslint-community/eslint-plugin-n/commit/cefdb1c26d856b544470e825daef2dfa5d0e4a30)), closes [#196](https://github.com/eslint-community/eslint-plugin-n/issues/196)
* **shebang:** add support for env's split-string option ([#195](https://github.com/eslint-community/eslint-plugin-n/issues/195)) ([b383b49](https://github.com/eslint-community/eslint-plugin-n/commit/b383b4971df4f4b67099655797b654b36d6a8fdf))
* Update ES Syntax ([#189](https://github.com/eslint-community/eslint-plugin-n/issues/189)) ([4778ae8](https://github.com/eslint-community/eslint-plugin-n/commit/4778ae86c398f90da13248c2d31bfc4a83cd2dea))


### Bug Fixes

* **no-unsupported-features:** Remove use of `static` as a variable ([#190](https://github.com/eslint-community/eslint-plugin-n/issues/190)) ([e31d868](https://github.com/eslint-community/eslint-plugin-n/commit/e31d8683b65a6f982cb91634f951afd0fe5583ae))


### Chores

* Enable global strict eslint rule ([#191](https://github.com/eslint-community/eslint-plugin-n/issues/191)) ([99fe387](https://github.com/eslint-community/eslint-plugin-n/commit/99fe38722d02de867f4bd8061a343b9754b62610))
* Migrate to manifest config ([#192](https://github.com/eslint-community/eslint-plugin-n/issues/192)) ([c8a87f3](https://github.com/eslint-community/eslint-plugin-n/commit/c8a87f3ef99348e547259f3939274cdf4da72b08))
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@ For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable
| [file-extension-in-import](docs/rules/file-extension-in-import.md) | enforce the style of file extensions in `import` declarations | | 🔧 | |
| [global-require](docs/rules/global-require.md) | require `require()` calls to be placed at top-level module scope | | | |
| [handle-callback-err](docs/rules/handle-callback-err.md) | require error handling in callbacks | | | |
| [hashbang](docs/rules/hashbang.md) | require correct usage of hashbang | ☑️ 🟢 ✅ ☑️ 🟢 ✅ | 🔧 | |
| [no-callback-literal](docs/rules/no-callback-literal.md) | enforce Node.js-style error-first callback pattern is followed | | | |
| [no-deprecated-api](docs/rules/no-deprecated-api.md) | disallow deprecated APIs | ☑️ 🟢 ✅ ☑️ 🟢 ✅ | | |
| [no-exports-assign](docs/rules/no-exports-assign.md) | disallow the assignment to `exports` | ☑️ 🟢 ✅ ☑️ 🟢 ✅ | | |
@@ -147,7 +148,7 @@ For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable
| [prefer-promises/dns](docs/rules/prefer-promises/dns.md) | enforce `require("dns").promises` | | | |
| [prefer-promises/fs](docs/rules/prefer-promises/fs.md) | enforce `require("fs").promises` | | | |
| [process-exit-as-throw](docs/rules/process-exit-as-throw.md) | require that `process.exit()` expressions use the same code path as `throw` | ☑️ 🟢 ✅ ☑️ 🟢 ✅ | | |
| [shebang](docs/rules/shebang.md) | require correct usage of shebang | ☑️ 🟢 ✅ ☑️ 🟢 ✅ | 🔧 | |
| [shebang](docs/rules/shebang.md) | require correct usage of hashbang | | 🔧 | |

<!-- end auto-generated rules list -->

88 changes: 88 additions & 0 deletions docs/rules/hashbang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Require correct usage of hashbang (`n/hashbang`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): ☑️ `flat/recommended`, 🟢 `flat/recommended-module`, ✅ `flat/recommended-script`, ☑️ `recommended`, 🟢 `recommended-module`, ✅ `recommended-script`.

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

<!-- end auto-generated rule header -->

When we make a CLI tool with Node.js, we add `bin` field to `package.json`, then we add a hashbang the entry file.
This rule suggests correct usage of hashbang.

## 📖 Rule Details

This rule looks up `package.json` file from each linting target file.
Starting from the directory of the target file, it goes up ancestor directories until found.

If `package.json` was not found, this rule does nothing.

This rule checks `bin` field of `package.json`, then if a target file matches one of `bin` files, it checks whether or not there is a correct hashbang.
Otherwise it checks whether or not there is not a hashbang.

The following patterns are considered problems for files in `bin` field of `package.json`:

```js
console.log("hello"); /*error This file needs hashbang "#!/usr/bin/env node".*/
```

```js
#!/usr/bin/env node /*error This file must not have Unicode BOM.*/
console.log("hello");
// If this file has Unicode BOM.
```

```js
#!/usr/bin/env node /*error This file must have Unix linebreaks (LF).*/
console.log("hello");
// If this file has Windows' linebreaks (CRLF).
```

The following patterns are considered problems for other files:

```js
#!/usr/bin/env node /*error This file needs no hashbang.*/
console.log("hello");
```

The following patterns are not considered problems for files in `bin` field of `package.json`:

```js
#!/usr/bin/env node
console.log("hello");
```

The following patterns are not considered problems for other files:

```js
console.log("hello");
```

### Options

```json
{
"n/hashbang": ["error", {
"convertPath": null,
"ignoreUnpublished": false,
"additionalExecutables": [],
}]
}
```

#### convertPath

This can be configured in the rule options or as a shared setting [`settings.convertPath`](../shared-settings.md#convertpath).
Please see the shared settings documentation for more information.

#### ignoreUnpublished

Allow for files that are not published to npm to be ignored by this rule.

#### additionalExecutables

Mark files as executable that are not referenced by the package.json#bin property

## 🔎 Implementation

- [Rule source](../../lib/rules/hashbang.js)
- [Test source](../../tests/lib/rules/hashbang.js)
4 changes: 2 additions & 2 deletions docs/rules/shebang.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Require correct usage of shebang (`n/shebang`)
# Require correct usage of hashbang (`n/shebang`)

💼 This rule is enabled in the following [configs](https://github.com/eslint-community/eslint-plugin-n#-configs): ☑️ `flat/recommended`, 🟢 `flat/recommended-module`, ✅ `flat/recommended-script`, ☑️ `recommended`, 🟢 `recommended-module`, ✅ `recommended-script`.
This rule is deprecated. It was replaced by [`n/hashbang`](hashbang.md).

🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).

5 changes: 4 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -28,7 +28,10 @@ module.exports = [
eslintPluginConfig,
prettierConfig,
{
rules: { "eslint-plugin/require-meta-docs-description": "error" },
rules: {
strict: ["error", "global"],
"eslint-plugin/require-meta-docs-description": "error",
},
},
{
// these messageIds were used outside
2 changes: 1 addition & 1 deletion lib/configs/_commons.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,6 @@ module.exports = {
"n/no-unsupported-features/es-syntax": "error",
"n/no-unsupported-features/node-builtins": "error",
"n/process-exit-as-throw": "error",
"n/shebang": "error",
"n/hashbang": "error",
},
}
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -43,10 +43,11 @@ const rules = {
"prefer-promises/dns": require("./rules/prefer-promises/dns"),
"prefer-promises/fs": require("./rules/prefer-promises/fs"),
"process-exit-as-throw": require("./rules/process-exit-as-throw"),
shebang: require("./rules/shebang"),
hashbang: require("./rules/hashbang"),

// Deprecated rules.
"no-hide-core-modules": require("./rules/no-hide-core-modules"),
shebang: require("./rules/shebang"),
}

const mod = {
Loading