You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(hashbang): Add support to map extensions to executables (#278)
* test: Rename shebang tests to be more verbose
* chore: Prepare for #220 by making shebang checks more verbose
* feat(hashbang): Add support to map extensions to executables
* chore: remove "\b" in char group
* docs(hashbang): Add docs for "executableMap"
Copy file name to clipboardexpand all lines: docs/rules/shebang.md
+1-70
Original file line number
Diff line number
Diff line change
@@ -11,76 +11,7 @@ This rule suggests correct usage of shebang.
11
11
12
12
## 📖 Rule Details
13
13
14
-
This rule looks up `package.json` file from each linting target file.
15
-
Starting from the directory of the target file, it goes up ancestor directories until found.
16
-
17
-
If `package.json` was not found, this rule does nothing.
18
-
19
-
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 shebang.
20
-
Otherwise it checks whether or not there is not a shebang.
21
-
22
-
The following patterns are considered problems for files in `bin` field of `package.json`:
23
-
24
-
```js
25
-
console.log("hello"); /*error This file needs shebang "#!/usr/bin/env node".*/
26
-
```
27
-
28
-
```js
29
-
#!/usr/bin/env node /*error This file must not have Unicode BOM.*/
30
-
console.log("hello");
31
-
// If this file has Unicode BOM.
32
-
```
33
-
34
-
```js
35
-
#!/usr/bin/env node /*error This file must have Unix linebreaks (LF).*/
36
-
console.log("hello");
37
-
// If this file has Windows' linebreaks (CRLF).
38
-
```
39
-
40
-
The following patterns are considered problems for other files:
41
-
42
-
```js
43
-
#!/usr/bin/env node /*error This file needs no shebang.*/
44
-
console.log("hello");
45
-
```
46
-
47
-
The following patterns are not considered problems for files in `bin` field of `package.json`:
48
-
49
-
```js
50
-
#!/usr/bin/env node
51
-
console.log("hello");
52
-
```
53
-
54
-
The following patterns are not considered problems for other files:
55
-
56
-
```js
57
-
console.log("hello");
58
-
```
59
-
60
-
### Options
61
-
62
-
```json
63
-
{
64
-
"n/shebang": ["error", {
65
-
"convertPath": null,
66
-
"ignoreUnpublished": false,
67
-
"additionalExecutables": [],
68
-
}]
69
-
}
70
-
```
71
-
72
-
#### convertPath
73
-
74
-
This can be configured in the rule options or as a shared setting [`settings.convertPath`](../shared-settings.md#convertpath).
75
-
Please see the shared settings documentation for more information.
76
-
77
-
#### ignoreUnpublished
78
-
79
-
Allow for files that are not published to npm to be ignored by this rule.
80
-
81
-
#### additionalExecutables
82
-
83
-
Mark files as executable that are not referenced by the package.json#bin property
14
+
The details for this rule can be found in [docs/rules/hashbang.md](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/hashbang.md#-rule-details)
0 commit comments