Shebang first line should be excluded from maximum line length
See original GitHub issueHaving the following error message which seems to be correct, and expected, but arguing for a slight change of policy here:
src/server/database.js|1 col 1 error| Line 1 exceeds the maximum line length of 100. (max-len)
I don’t think shebangs should count when checking maximum line length. The motivation for this is given the extreme difficulties (polyglot) multi-line shebangs bring to the table, add to that the common use practice of having shell executable node.js programs, one is inclined to think a configuration such as below, is a viable form of opening a JS file (this is what actually triggered the error).
#!/usr/bin/env NODE_PATH='.' NODE_ENV='development' NODE_CONFIG_DIR='./config' /usr/local/bin/babel-node
The point regarding this is backed even further (I feel) by the fact that a lot of these so-called environment variables, usually found in either system-, or user-wide shell scope really don’t apply so much to quite a few Node.js variables (or how they are used). E.g. I can have plenty of projects all with different env a few with development, others with production. Same goes for config… (ok doesn’t make for very good practice to keep changing around the config path, but you get my drift).
Now it is also considered bad practice to set environment variables from (JS) code, e.g. process.env.NODE_PATH = '.'
(doesn’t work actually, too late for that but the following does) or process.env.NODE_ENV = 'development';
.
From this, I’ve come to conclude in a most of our use cases, the shebangs are really the most viable solution to cleanly and reliably set these conditions in quickly to run one-off scripts, for testing, debugging, development etc. (the production services all rely on systemd service environment variables).
It goes without saying that I rather not set the whole eslint to allow for e.g. 120 columns or beyond.
Thoughts?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Closing this because we haven’t moved forward with it in months.
Ah… thanks for the tip shreevatsa.