Open stof opened 5 years ago
Most rules won't be fixable, but that will still be nice for the few ones benefiting from this.
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
Here's a first pass of rules we could probably write fixers for:
(moved to first comment)
$.now()
can be migrated to Date.now()
easily too
Date.now()
is es6 and we'd like to maintain compatibility with es5 for now.
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.
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, whereasmyUndefinedVar.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.
Some of the rules could be fixed quite easily. For instance, migrating from
$.isArray()
toArray.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: