Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove jslint.js' need for directive /*jslint long */ to lint itself, by ignore long regexp's (and comments) #231

Conversation

kaizhu256
Copy link
Member

this patch will allow jslint.js to successfully lint itself with without the directive /*jslint long */,
by ignoring long-lines containing regexp's and comments.

i find ignoring long-comments, like source-code references to stackoverlow useful (see screenshot).

live web-demo of patch available at:
https://kaizhu256.github.io/JSLint/branch.jslint_pass_itself_without_long_option/index.html

yay! jslint.js passes without needing long-option
screen shot 2018-09-14 at 11 47 10 pm

example where a long-comment (reference-link to stackoverflow) can be useful.
note that the long code-line still triggers a warning.
screen shot 2018-09-14 at 11 47 13 pm

@douglascrockford
Copy link
Collaborator

I have long regexps because currently the language does not provide a way to break them into smaller chunks. I am hopeful that that will be repaired someday.

The language already as support for breaking comments.

@kaizhu256
Copy link
Member Author

I have long regexps because currently the language does not provide a way to break them into smaller chunks. I am hopeful that that will be repaired someday.

that's likely not going to happen in the forseeable future, given the current sentiment of tc39 to be more cautious with syntax changes. instead of wishful thinking on a more-or-less [permanent] todo, perhaps it would make more sense to break the regexp literal as a string with a RegExp call?

const rx_token = new RegExp(
    "^((\\s+)|([a-zA-Z_$][a-zA-Z0-9_$]*)|[(){}\\[\\]?,:;'\"~`]|=(?:==?|>)?|\\.+"
    + "|[*\\/][*\\/=]?|\\+[=+]?|-[=\\-]?|[\\^%]=?|&[&=]?|\\|[|=]?|>{1,3}=?"
    + "|<<?=?|!(?:!|==?)?|(0|[1-9][0-9]*))(.*)$"
);

@douglascrockford
Copy link
Collaborator

Thanks. Please try it now.

@jslint-org jslint-org deleted a comment from kaizhu256 Sep 25, 2018
@kaizhu256 kaizhu256 deleted the jslint_pass_itself_without_long_option branch June 14, 2021 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants