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

Implement fixable rules when possible #115

Open
17 of 25 tasks
stof opened this issue Sep 26, 2019 · 7 comments
Open
17 of 25 tasks

Implement fixable rules when possible #115

stof opened this issue Sep 26, 2019 · 7 comments

Comments

@stof
Copy link
Contributor

stof commented Sep 26, 2019

Some of the rules could be fixed quite easily. For instance, migrating from $.isArray() to Array.isArray is straightforward.
It would be great if such rules could be implemented as fixable, so that ESLint can fix them automatically.

Ed: Adding checklist here so it comes up in the task list:

  • no-and-self
  • no-bind
  • no-delegate
  • no-die
  • no-error
  • no-error-shorthand
  • no-event-shorthand
  • no-extend
  • no-is-array
  • no-is-function
  • no-live
  • no-load
  • no-noop
  • no-now
  • no-on-ready
  • no-parse-json
  • no-parse-xml
  • no-proxy
  • no-ready-shorthand
  • no-size
  • no-type
  • no-unbind
  • no-undelegate
  • no-unique
  • no-unload-shorthand
@stof
Copy link
Contributor Author

stof commented Sep 26, 2019

Most rules won't be fixable, but that will still be nice for the few ones benefiting from this.

edg2s added a commit that referenced this issue Sep 26, 2019
jdforrester pushed a commit that referenced this issue Sep 26, 2019
* Create a fixer for no-is-array

Part of #115

* Check fix is defined
@edg2s
Copy link
Member

edg2s commented Sep 26, 2019

Note that some rules will have subtle changes that mean we can't autofix, for example handling undefined arguments:
$.inArray( myUndefinedVar, 'foo' )
will not throw, whereas myUndefinedVar.indexOf will

@edg2s
Copy link
Member

edg2s commented Sep 27, 2019

Here's a first pass of rules we could probably write fixers for:

(moved to first comment)

@stof
Copy link
Contributor Author

stof commented Sep 30, 2019

$.now() can be migrated to Date.now() easily too

@edg2s
Copy link
Member

edg2s commented Sep 30, 2019

Date.now() is es6 and we'd like to maintain compatibility with es5 for now.

@stof
Copy link
Contributor Author

stof commented Oct 1, 2019

Date.now is supported in IE9+: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Browser_compatibility

Btw, $.now() is implemented using Date.now() already: https://github.com/jquery/jquery/blob/3.4.1/src/deprecated.js#L82
So using it will not regress browser support.

Btw, it is part of ES 5.1, not of ES 6.

edg2s added a commit that referenced this issue Oct 3, 2019
jdforrester pushed a commit that referenced this issue Oct 3, 2019
edg2s added a commit that referenced this issue Oct 12, 2019
edg2s added a commit that referenced this issue Oct 12, 2019
edg2s added a commit that referenced this issue Oct 12, 2019
edg2s added a commit that referenced this issue Oct 12, 2019
edg2s added a commit that referenced this issue Oct 12, 2019
Also adds fixers for:
* `no-error-shorthand`
* `no-load-shorthand`
* `no-unload-shorthand`

Add 'load' and 'unload' to `no-event-shorthand`.

See #115
edg2s added a commit that referenced this issue Oct 13, 2019
jdforrester pushed a commit that referenced this issue Oct 15, 2019
Also adds fixers for:
* `no-error-shorthand`
* `no-load-shorthand`
* `no-unload-shorthand`

Add 'load' and 'unload' to `no-event-shorthand`.

See #115
jdforrester pushed a commit that referenced this issue Oct 15, 2019
jdforrester pushed a commit that referenced this issue Oct 15, 2019
edg2s added a commit that referenced this issue Dec 26, 2019
jdforrester pushed a commit that referenced this issue Jan 6, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
Also fix copy/paste error in valid cases.

Part of #115
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
Also fix copy/paste error in valid cases.

Part of #115
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
Also fix copy/paste error in valid cases.

Part of #115
edg2s added a commit that referenced this issue Oct 8, 2020
jdforrester pushed a commit that referenced this issue Oct 8, 2020
Also fix copy/paste error in valid cases.

Part of #115
jdforrester pushed a commit that referenced this issue Oct 8, 2020
jdforrester pushed a commit that referenced this issue Oct 8, 2020
edg2s added a commit that referenced this issue Oct 8, 2020
jdforrester pushed a commit that referenced this issue Apr 7, 2021
* Pass context to fixers

* Add fixer for no-proxy

Part of #115
@edg2s
Copy link
Member

edg2s commented Sep 3, 2021

Note that some rules will have subtle changes that mean we can't autofix, for example handling undefined arguments:
$.inArray( myUndefinedVar, 'foo' )
will not throw, whereas myUndefinedVar.indexOf will

Rules that can't be auto-fixed can be implemented as suggestions. The message can be used to explain the limitations of the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants