Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

☂️ Implement Regex Rules #159

Closed
11 of 23 tasks
Kelbie opened this issue Mar 9, 2020 · 37 comments
Closed
11 of 23 tasks

☂️ Implement Regex Rules #159

Kelbie opened this issue Mar 9, 2020 · 37 comments
Labels
umbrella Issue to track a collection of other issues

Comments

@Kelbie
Copy link
Contributor

Kelbie commented Mar 9, 2020

Followed is a list of ESLint rules that we should implement.

Please comment if you want to work on one of these and I'll mark you to avoid duplicating work. Mentions next to rules indicate that someone else is working on it. If a PR isn't opened within a few days then it will be up for grabs.

A checkmark indicates an open PR.

A reference implementation of these features can be found here

@Kelbie Kelbie added the umbrella Issue to track a collection of other issues label Mar 9, 2020
@Kelbie
Copy link
Contributor Author

Kelbie commented Mar 9, 2020

@sebmck let me know if there are any rules we shouldn't implement that are listed here.

@zinyando
Copy link
Contributor

@KevinKelbie I'd love to help work on these but I'm not sure what they are, can you give me a quick summary and a link to an example implementation in Rome. Which file do we put the rules in also?

@tatchi
Copy link
Contributor

tatchi commented Mar 10, 2020

Hey,

I would like to work on dupname :)

@Kelbie
Copy link
Contributor Author

Kelbie commented Mar 10, 2020

@zinyando I think the main file you want to look at is here because that's were the other rules are located such as Invalid capture group modifier, Unclosed group and Unclosed character set. Additionally there is another project which has implemented a lot of these features which you can use as a guide. I've not implemented a regex rule myself and am just peicing together what I can so if anyone knows more than I do please correct me.

@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2020

@tatchi Tip: Use the RegExpGroupCapture node and name property

@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2020

Note that there are also some missing syntax implementation in the regex parser. Notably some unicode escapes and backreferences. Happy to accept PRs if anyone wants to implement them.

@baryla
Copy link

baryla commented Mar 10, 2020

I'll have a go at the fwdslash one 🙂

@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2020

Unclear how the fwdslash one would work since it will be a JS syntax error. I believe that rule only exists in regexr because you paste in regex bodies.

@baryla
Copy link

baryla commented Mar 10, 2020

@sebmck that is a fair shout. Should that be taken out then since it may not apply to Rome?

@baryla
Copy link

baryla commented Mar 10, 2020

If we're unsure how to tackle fwdslash or if it should be implemented into the regex rules, I can look at setopen in the meantime :)

@stephenwf
Copy link

Are RegExp constructor calls (new Regex('...')) ignored?

@sebmck
Copy link
Contributor

sebmck commented Mar 10, 2020

@stephenwf They are. I think we should leave them as-is for the timebeing. We should figure out some strategy to extract the regex, explode it into a RegExpLiteral, run the compiler over it, and then reserialize it. It would allow us to have transforms and lints "just work" and avoid having to special case it and risk performance regressions by having to parse it all over the place.

@tatchi
Copy link
Contributor

tatchi commented Mar 11, 2020

Hey,

I can work on the badname one :)

@diokey
Copy link
Contributor

diokey commented Mar 12, 2020

Hi there,
I'd like to try esccharopen

@zinyando
Copy link
Contributor

I'll try tackling extraelse

@zinyando
Copy link
Contributor

I'll take on unicodebad

@Kelbie
Copy link
Contributor Author

Kelbie commented Mar 14, 2020

I'll do quantrev

@wgardiner
Copy link
Contributor

@KevinKelbie are POSIX character classes supported in javascript regex? It looks like Regexr only supports them for the PCRE engine.

@Kelbie
Copy link
Contributor Author

Kelbie commented Mar 15, 2020

@wgardiner that does seem to be the case. Could we still add some linting to tell the user that its not a supported feature in the javascript version of regex?

@wgardiner
Copy link
Contributor

@KevinKelbie Sure, I can add a lint rule to throw an error for POSIX character classes and POSIX collating sequences

@ghost
Copy link

ghost commented Mar 17, 2020

I'll take a stab at quanttarg.

I need to check to see if the unquantifiable types are defined but if not hopefully I can add those.

@Kelbie
Copy link
Contributor Author

Kelbie commented Mar 17, 2020

@caffeinateoften I'll probably make a PR for quantrev today. Just so you know there are currently some bugs with the quantifier node but I've created fixes for them so that should help with your lint rule.

@diokey
Copy link
Contributor

diokey commented Mar 19, 2020

I'd like to try unmatchedref next

@ParkourKarthik
Copy link

I'd love to contribute. I'll pick up esccharbad. I need some help on where I could start and other specific references if any.

@macovedj
Copy link
Contributor

Guess I'll jump in. Can I claim modebad?

@macovedj
Copy link
Contributor

I might not understand badmode correctly, but it appears that this function actually does what I expected this issue to be about.

@Kelbie
Copy link
Contributor Author

Kelbie commented Mar 22, 2020

@macovedj I think your right however I find the error message to not be that helpful. It would be nice if the underline was under the incorrect flags rather than the start of the regex. What do you think?
Screenshot 2020-03-22 at 00 43 40

@1ntEgr8
Copy link
Contributor

1ntEgr8 commented Mar 26, 2020

I can pick up timeout!

@ghost
Copy link

ghost commented Mar 27, 2020

I never commented here but I opened a PR for quanttarg #189 a few days ago!

@macovedj
Copy link
Contributor

@KevinKelbie I think that mode-bad became obsolete as the underline no longer appears after changes made by @sebmck, and instead there is a color change in the text that correctly is applied to the first problematic flag. If you agree then we can close #195 and if there's something else you think should be done then let me know.

@Kelbie
Copy link
Contributor Author

Kelbie commented Apr 5, 2020

@macovedj sorry for the late response, the underline still appears for me on master. The colour change is the autofixer and both appear for me.

Screenshot 2020-04-05 at 12 59 53

@macovedj
Copy link
Contributor

macovedj commented Apr 16, 2020

@KevinKelbie Have you seen that is ready for review again? Also, is my understanding of branchreseterr correct in that you basically just want us to throw an error whenever anybody attempts to use a branch reset group? If so I could pick that up, or maybe another after a question or two. Finally, do we have a way of knowing which items have been claimed but aren't being acted on? Also curious if this is knowable for eslint @sebmck. Asking mostly because I'd like to pick up more work, but don't feel that I have sufficient context on the formatter and don't know that I see other issues that I know enough about to grab, rather than because I'd like people to hurry up. I'd hate for anybody to feel rushed by this comment. Still learning proper open source etiquette.

@Kelbie
Copy link
Contributor Author

Kelbie commented Apr 16, 2020

Have you seen that is ready for review again?

Awesome!

Finally, do we have a way of knowing which items have been claimed but aren't being acted on?

It's been almost a month since we have heard anything from some of the assignees so I'd be happy to re-assign someone else to some of these issues. If anyone is stuggling with implementing their rule they have taken I'm sure some people on the discord would be able to point you in the right direction.

If you are taking on an already assigned rule then perhaps you could tag the assignee to let them know and wait a day to let them respond.

@sebmck
Copy link
Contributor

sebmck commented Apr 20, 2020

Feel free to take on rules that have been assigned but have had no movement on.

@macovedj
Copy link
Contributor

Cool I'll probably start with some of the non-regex ones since they're older.

@VictorHom
Copy link
Contributor

VictorHom commented May 9, 2020

Can I work on rangerev? (I see the checkmark, but not sure if there is a pr)

turns out the rule was completed already

@sebmck
Copy link
Contributor

sebmck commented May 21, 2020

Copying what I mentioned in #20

I think this can be closed out in favor of more specific issues. I don't think we should focus on other general JS lint rules at this time. Let's move towards a release! Thanks everyone for your contributions so far. I encourage you to get involved in #341 (React lint rules), #18 (Published release) or #496 (Website for release).

Thank you everyone!

@sebmck sebmck closed this as completed May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
umbrella Issue to track a collection of other issues
Projects
None yet
Development

No branches or pull requests