When we make a CLI tool on Node.js, we add bin
field to package.json
, then we add a shebang the entry file.
This rule suggests correct usage of shebang.
This rule looks up package.json
file from each linitng 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 shebang.
Otherwise it checks whether or not there is not a shebang.
The following patterns are considered problems:
console.log("hello"); /*error This file needs shebang "#!/usr/bin/env node".*/
The following patterns are considered not problems:
#!/usr/bin/env node
console.log("hello");
The following patterns are considered problems:
#!/usr/bin/env node /*error This file needs no shebang.*/
console.log("hello");
The following patterns are considered not problems:
console.log("hello");
If you don't want to be notified about usage of shebang, then it's safe to disable this rule.