-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
max-len to ignore Regular Expressions #3229
Comments
Thanks for the issue! We get a lot of issues, so this message is automatically posted to each one to help you check that you've included all of the information we need to help you. Reporting a bug? Please be sure to include:
Requesting a new rule? Please be sure to include:
Requesting a feature? Please be sure to include:
Including this information in your issue helps us to triage it and get you a response as quickly as possible. Thanks! |
See the |
@nzakas could you please share an example of the RegExp that describes a line containing regexp definition only, possibly with an assignment to a variable? I think the expression would be pretty complex and thus it may be better to implement his particular exception as a first-class eslint option. Here is an example of what I would like to achieve: // assuming max-len 4, these are considered valid:
var foo = /asd/;
foo(
x,
/asd/
);
// this is not valid - the comment should be on a different line
var foo = /asd/; /* trailing comment */
// this is not valid - function arguments should be split to multiple lines
foo(x, /asd/); For example, jscs's Thoughts? |
It was quite popular option - to ignore regular expression, it was used in jquery preset and other derivates like grunt and wordpress. In order to increase compatibility with jscs i would like to put this back to agenda and allow myself to reopen this ticket |
@markelog can you explain your proposal? |
Sure, regular expression could be very long - like so https://github.com/jquery/jquery/blob/95c7ab68970ce201a2bbff48c8e951d38c228ce8/src/manipulation.js#L32, divide them like It would be cool if this rule would have an option which would allow to ignore such long regexes, same as maximumLineLength |
@markelog sorry, what I meant was, what is your proposal for the new rule option? |
Sorry, missed your comment, how about |
Sorry, what I meant was can you put together a proposal based on our guidelines (http://eslint.org/docs/developer-guide/contributing/rule-changes). This issue was closed because there wasn't enough info, so before we can move forward, we need a concrete proposal. |
Sorry, forgot about this bit, you want me to create another issue or do it here? |
You can do it here (in the future, though, opening a new issue would be better). |
So is there still need to make this proposal more concrete or is it valid as-is? |
@Herst still waiting for a concrete proposal. |
Sorry for the delay - "max-len": [
"error",
{
"code": 5,
"ignoreRegex": true
}
] Valid: var re = /w+/; Invalid: var re = "test"; If there is something i can make more clear, would you mind pointing me to the example? |
@markelog that looks good! We just needed something concrete to discuss. I'm assuming that you are championing this change? |
@nzakas Totally, can we label this as |
👍 |
1 similar comment
👍 |
ok-ok, thanks, i'm on it :) |
I use ignorePattern for work around this. this regex will match codes like |
@chenzhenxi Shouldn't that be forward slashes? |
@Herst good catch, I edited my comment. |
@markelog Any progress on this? :) |
Yeah, slowly but surely |
Would appreciate clean solution. as a workaround I'm using: // eslint-disable-next-line max-len
url: /(<my_very_long_regex>)/, |
I'm locking this conversation because the work is underway and the approach has already been discussed. |
This was fixed in 644d25b, not sure why the issue wasn't closed automatically. |
Since it looks like this issue was causing some confusion: The new option is |
Is there a way to add an option to ignore regular expressions that are too long? Sometimes those things can get huge. For example, URI.js needs a very long regex to parse a URL: https://github.com/medialize/URI.js/blob/gh-pages/src/URI.js#L207
The text was updated successfully, but these errors were encountered: