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

Implement ESLint rules #94

Closed
27 tasks done
sebmck opened this issue Mar 2, 2020 · 42 comments
Closed
27 tasks done

Implement ESLint rules #94

sebmck opened this issue Mar 2, 2020 · 42 comments

Comments

@sebmck
Copy link
Contributor

sebmck commented Mar 2, 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.

@sebmck sebmck mentioned this issue Mar 2, 2020
@yangshun
Copy link
Contributor

yangshun commented Mar 2, 2020

I'd like to try working on no-debugger

@weblancaster
Copy link
Contributor

I started working on no-delete-var

@JayaKrishnaNamburu
Copy link

JayaKrishnaNamburu commented Mar 2, 2020

I would like to try working on no-unreachable

@tanhauhau
Copy link
Contributor

I'd like to try on no-async-promise-executor

@zinyando
Copy link
Contributor

zinyando commented Mar 2, 2020

I'd like to try taking on no-dupe-args

@mattcompiles
Copy link
Contributor

Taking a look at no-dupe-keys

@zinyando
Copy link
Contributor

zinyando commented Mar 2, 2020

I'm taking on no-duplicate-case

@gobeli
Copy link

gobeli commented Mar 2, 2020

Would take no-label-var

@yangshun
Copy link
Contributor

yangshun commented Mar 2, 2020

I've added links to the ESLint rule documentation, src implementation and test implementation as it might be useful for people working on them.


  • enforce return statements in getters (getter-return)
  • disallow using an async function as a Promise executor (no-async-promise-executor)
  • disallow comparing against -0 (no-compare-neg-zero)
  • disallow assignment operators in conditional expressions (no-cond-assign)
  • disallow the use of debugger (no-debugger)
  • disallow duplicate arguments in function definitions (no-dupe-args)
  • disallow duplicate keys in object literals (no-dupe-keys)
  • disallow a duplicate case label (no-duplicate-case)
  • disallow empty character classes in regular expressions (no-empty-character-class)
  • disallow reassigning exceptions in catch clauses (no-ex-assign)
  • disallow unnecessary boolean casts (no-extra-boolean-cast)
  • disallow reassigning function declarations (no-func-assign)
  • disallow assigning to imported bindings (no-import-assign)
  • disallow variable or function declarations in nested blocks (no-inner-declarations)
  • disallow invalid regular expression strings in RegExp constructors (no-invalid-regexp)
  • disallow multiple spaces in regular expression literals (no-regex-spaces)
  • disallow returning values from setters (no-setter-return)
  • disallow sparse arrays (no-sparse-arrays)
  • disallow unreachable code after return, throw, continue, and break statements (no-unreachable)
  • disallow control flow statements in finally blocks (no-unsafe-finally)
  • disallow negating the left operand of relational operators (no-unsafe-negation)
  • disallow template literal placeholder syntax in regular strings (no-template-curly-in-string)
  • disallow deleting variables (no-delete-var)
  • disallow labels that are variable names (no-label-var)
  • disallow shadowing of restricted names (no-shadow-restricted-names)
  • suggest template literals instead of string concatenation (prefer-template)

@yangshun
Copy link
Contributor

yangshun commented Mar 2, 2020

Some general observations/thoughts while working on the noDebugger rule:

  • Not clear how to test for both valid and invalid cases. Would be good to have a format similar to ESLint's where contributors just specify the valid and invalid patterns along with desired errors
  • Might want to sort the exports in packages/@romejs/js-compiler/transforms/lint/index.ts alphabetically to reduce the chance of merge conflicts. From looking at the PRs, there will be quite a few merge conflicts as most people add it to the bottom js-compiler: sort lint imports #132
  • Might want to sort the cases within packages/@romejs/js-compiler/__rtests__/lint.ts or start a convention of one test file per rule. Lowers the chance of merge conflicts and smaller files are easier to read js-compiler: split lint tests into individual files #140
  • The unusedVariables rule is firing on the other lint rules tests. Would be nice to have a way to silence it for other tests

@JayaKrishnaNamburu
Copy link

Hey is anyone interested in discussing some pointers on implementation of no-unreachable implementation. I tried some way, but one way or the other few edge cases are failing when tested over eslint test rules 😓 😅

@jloleysens
Copy link
Contributor

Taking no-compare-neg-zero

@macovedj
Copy link
Contributor

macovedj commented Mar 2, 2020

@JayaKrishnaNamburu Sounds like one of the more fun ones. I'd be interested in thinking about it. Got a branch up yet?

@JayaKrishnaNamburu
Copy link

JayaKrishnaNamburu commented Mar 2, 2020

Sure @macovedj i will update it tomorrow and let's discuss there 😄

@sebmck
Copy link
Contributor Author

sebmck commented Mar 2, 2020

@JayaKrishnaNamburu

Hey is anyone interested in discussing some pointers on implementation of no-unreachable implementation. I tried some way, but one way or the other few edge cases are failing when tested over eslint test rules sweat sweat_smile

I don't think it would be as straightforward as ESLint since we don't have the same concept of code paths. It's fine if it's not as smart. Rome has a more sophisticated analysis system in js-analysis that we can utilize in the far future for something even better.

@sebmck
Copy link
Contributor Author

sebmck commented Mar 2, 2020

I've updated the main issue body with the latest PRs.

@mattcompiles
Copy link
Contributor

My user is @MattsJones not @MattJones btw 😅

@sebmck
Copy link
Contributor Author

sebmck commented Mar 2, 2020

Oops, sorry @MattJones 😛

@eliassotodo
Copy link

I will work on no-template-curly-in-string

@wgardiner
Copy link
Contributor

I'll take no-func-assign

@JayaKrishnaNamburu
Copy link

@JayaKrishnaNamburu

Hey is anyone interested in discussing some pointers on implementation of no-unreachable implementation. I tried some way, but one way or the other few edge cases are failing when tested over eslint test rules sweat sweat_smile

I don't think it would be as straightforward as ESLint since we don't have the same concept of code paths. It's fine if it's not as smart. Rome has a more sophisticated analysis system in js-analysis that we can utilize in the far future for something even better.

Sure, Thank you. I will continue my work then 👍 😄

@mattcompiles
Copy link
Contributor

Happy to pickup no-shadow-restricted-names. ESLint currently only handles "undefined", "NaN", "Infinity", "arguments", "eval".

I was thinking we should block everything matching scope.getRootScope().isGlobal(name)?

@sebmck
Copy link
Contributor Author

sebmck commented Mar 3, 2020

Sounds good to me!

@weblancaster
Copy link
Contributor

Picking up no-ex-assign

@emmatown
Copy link
Contributor

emmatown commented Mar 3, 2020

I'll pick up no-import-assign

@zinyando
Copy link
Contributor

zinyando commented Mar 3, 2020

I'm taking on no-unsafe-finally

@ikeryo1182
Copy link
Contributor

ikeryo1182 commented Mar 3, 2020

I will pick up no-regex-spaces

@torifat
Copy link
Contributor

torifat commented Mar 3, 2020

I'm taking no-setter-return. Want to try a simple one first 🙂
I'm taking prefer-template

@macovedj
Copy link
Contributor

macovedj commented Mar 3, 2020

I can do getter-return

@sebmck
Copy link
Contributor Author

sebmck commented Mar 3, 2020

Updated the issue body. Thanks everyone! Super happy and appreciative of all the PRs so far!

@Kelbie
Copy link
Contributor

Kelbie commented Mar 3, 2020

I can do no-empty-character-class

@tatchi
Copy link
Contributor

tatchi commented Mar 4, 2020

I would like to try no-inner-declarations (hopefully it's not too complex 😄)

@zinyando
Copy link
Contributor

zinyando commented Mar 4, 2020

I'm going to try to work on no-extra-boolean-cast

@macovedj
Copy link
Contributor

macovedj commented Mar 4, 2020

picking up prefer-template

@Kelbie
Copy link
Contributor

Kelbie commented Mar 4, 2020

I'll take on no-invalid-regexp

@sebmck
Copy link
Contributor Author

sebmck commented Mar 25, 2020

There's been some changes to structure since this issue was created and many of the PRs submitted. I just created a PR that adds a simple rule #196 and included some instructions that will hopefully be helpful to others.

This was referenced Apr 16, 2020
@thecodrr
Copy link
Contributor

thecodrr commented Apr 22, 2020

@sebmck can you please update the list? I see some rules in the list that are unchecked but are already implemented. Oh and I implemented no-inner-declarations rule (#305) since @tatchi never made a PR. So please update accordingly.

Edit: Actually, all of them are done after my PR. Unless you add some more, this can be closed?

@tatchi
Copy link
Contributor

tatchi commented Apr 22, 2020

@thecodrr actually I did open a PR #142 but we decided to close it. Sorry, I should have added a comment here.

@thecodrr
Copy link
Contributor

@tatchi and I should have confirmed (and researched) before jumping to implementation. 😆 Duplicate efforts. haha

@sebmck
Copy link
Contributor Author

sebmck commented Apr 22, 2020

It actually looks like all these rules have been implemented or deferred. If anyone has any other ideas for lint rules, whether ones that already exist, or new ones that are made easier/justified with an easy autofix, please open an issue to discuss!

@sebmck sebmck closed this as completed Apr 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests