Skip to content

Commit

Permalink
feat(eslint-config): add rule es-x/no-hashbang
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Dec 19, 2024
1 parent e36c13c commit a6a67fe
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-seahorses-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fenge/eslint-config": patch
---

feat(eslint-config): add rule `es-x/no-hashbang`
1 change: 1 addition & 0 deletions packages/eslint-config/src/config/js/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export function getJsBase() {
"es-x/no-accessor-properties": "error",
"es-x/no-async-iteration": "error",
"es-x/no-generators": "error",
"es-x/no-hashbang": "error",
"es-x/no-legacy-object-prototype-accessor-methods": "error",
"es-x/no-top-level-await": "error",
// esm
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/src/config/js/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export function getJsCli() {
name: "fenge/javascript/cli",
files: ["**/*.cli.{js,cjs,mjs,jsx}"],
rules: {
"es-x/no-hashbang": "off",
"es-x/no-top-level-await": "off",
"n/no-process-exit": "off",
// "unicorn/no-process-exit": "off", // This rule can detect a file if is a cli file, so there is no need to disable it here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ The bin file should starts with a hashbang
{"bin":[]}
{"bin":{"foo":true}}
{"bin":"./no-existing.js"} // filename: /foo/test/required-hashbang/package.json
{"bin":"./bad.js"} // filename: /foo/test/required-hashbang/package.json
{"bin":{"foo":"./bad.js"}} // filename: /foo/test/required-hashbang/package.json
{"bin":"./bad.cli.js"} // filename: /foo/test/required-hashbang/package.json
{"bin":{"foo":"./bad.cli.js"}} // filename: /foo/test/required-hashbang/package.json
```

### Pass
Expand All @@ -22,7 +22,7 @@ The bin file should starts with a hashbang
{}
{"name":"foo"}
{"bin":{}}
{"bin":"./good.js"} // filename: /foo/test/required-hashbang/package.json
{"bin":{"foo":"./good.js","bar":"./good.js"}} // filename: /foo/test/required-hashbang/package.json
{"bin":"./good.cli.js"} // filename: /foo/test/required-hashbang/package.json
{"bin":{"foo":"./good.cli.js","bar":"./good.cli.js"}} // filename: /foo/test/required-hashbang/package.json
```
<!-- prettier-ignore-end -->
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const valid = [
{ code: s({ name: "foo" }), filename: undefined },
{ code: s({ bin: {} }), filename: undefined },
{
code: s({ bin: "./good.js" }),
code: s({ bin: "./good.cli.js" }),
filename: path.join(dir, "../../test/required-hashbang/package.json"),
},
{
code: s({ bin: { foo: "./good.js", bar: "./good.js" } }),
code: s({ bin: { foo: "./good.cli.js", bar: "./good.cli.js" } }),
filename: path.join(dir, "../../test/required-hashbang/package.json"),
},
];
Expand All @@ -29,11 +29,11 @@ const invalid = [
filename: path.join(dir, "../../test/required-hashbang/package.json"),
},
{
code: s({ bin: "./bad.js" }),
code: s({ bin: "./bad.cli.js" }),
filename: path.join(dir, "../../test/required-hashbang/package.json"),
},
{
code: s({ bin: { foo: "./bad.js" } }),
code: s({ bin: { foo: "./bad.cli.js" } }),
filename: path.join(dir, "../../test/required-hashbang/package.json"),
},
];
Expand Down
2 changes: 1 addition & 1 deletion packages/tsconfig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"author": "[email protected]",
"type": "module",
"exports": {
"./cli": "./dist/cli.js",
"./cli": "./dist/tsconfig.cli.js",
"./setup": "./dist/setup.js",
"./cjs.json": "./cjs.json",
"./esm.json": "./esm.json",
Expand Down
File renamed without changes.

0 comments on commit a6a67fe

Please sign in to comment.