nkt / eslint-plugin-es5 Goto Github PK
View Code? Open in Web Editor NEWESLint plugin for ES5 users.
Home Page: https://www.npmjs.com/package/eslint-plugin-es5
License: MIT License
ESLint plugin for ES5 users.
Home Page: https://www.npmjs.com/package/eslint-plugin-es5
License: MIT License
I found new shiny 1.2.0 release but didn't found an easy way to find what rule was added :'(.
Here is other reasons to have ChangeLog http://keepachangelog.com/
It's possible to specify individual files as being written for ES6 environment using:
/* eslint-env es6 */
This should prevent the es5 rules being applied to the file.
plugin:es5/no-es2015
presets are great. But we could go further.
Main problem with ES2015+ features is compatibility problems. So let’s create a preset based on browsers, node version. Like: plugin:es5/ie
, plugin:es5/modern-browsers
(only Edge), plugin:es5/node4
.
First: thank you for this plugin, it's pretty useful. I prefer to use the baseline JavaScript for the legaciest browser I support, i.e. IE11. For keeping my JS fully IE11 compatible I can disable the no-block-scope
rule since that is OK most of the time. But it seems that IE11 doesn't like const
declarations in for (const item in items)
loops. It'd be really cool if this plugin added a rule or expanded the options of the block scoping rule to (dis-)allow this usage of const
. Thanks, again, have a nice day!
When a new PR is opened, kick off a CircleCI build running the linter and tests (npm test
).
awesome-eslint is a main promotion list about ESLint plugins.
It appears that this plugin does not catch instances of async/await in code. My current setup:
I am currently bundling my code with Webpack 4 and using dynamic import()
static import from
in my otherwise ES5 JS files. When I started using import()
, I was getting a parsing error:
error: Parsing error: Unexpected token import at ....
And according to many other threads, they suggest using the "babel-eslint" parser so I added that to my .eslintrc.
(vuejs/eslint-plugin-vue#204)
But now, async/await (and maybe other things?) are successfully being parsed and then not being caught by this plugin.
I would think that this plugin should catch all non-ES5 compliant code which is why I am filing this bug. If you are aware of another way to use dynamic import()
with eslint without the "babel-eslint" plugin, I would also be interested in that approach and relying on parsing errors for non ES5 language constructs.
Thanks!
I'm using your es5 plugin which is very nice however eslint still is not complaining about const
and let
.
Unfortunately our environment does not support const
nor let
(which come from es6)
The project has no ChangeLog.md
and Releases
miss 1.4 and 1.5. What were features of that 2 releases?
I think it will be good promotion for project.
Don’t forget to:
I expected the no-es6-methods
rule to accept an exceptMethods
option, the same way that no-es6-static-methods
does. However, it does not.
So I used patch-package to patch [email protected]
to add that rule option:
diff --git a/node_modules/eslint-plugin-es5/src/rules/no-es6-methods.js b/node_modules/eslint-plugin-es5/src/rules/no-es6-methods.js
index b313f28..260cbd1 100644
--- a/node_modules/eslint-plugin-es5/src/rules/no-es6-methods.js
+++ b/node_modules/eslint-plugin-es5/src/rules/no-es6-methods.js
@@ -52,9 +52,22 @@ module.exports = {
docs: {
description: 'Forbid methods added in ES6'
},
- schema: []
+ schema: [{
+ type: 'object',
+ properties: {
+ exceptMethods: {
+ type: 'array',
+ items: {
+ type: 'string'
+ }
+ }
+ }
+ }]
},
create(context) {
+ const options = Object.assign({ exceptMethods: [] }, context.options[0]);
+ const exceptMethods = new Set(options.exceptMethods);
+
return {
CallExpression(node) {
if(!node.callee || !node.callee.property) {
@@ -77,7 +90,7 @@ module.exports = {
const es6Functions = [].concat(
es6ArrayFunctions,
es6StringFunctions
- );
+ ).filter((name) => !exceptMethods.has(name));
if (es6Functions.indexOf(functionName) > -1 && !isPermitted(node.callee)) {
context.report({
node: node.callee.property,
This issue body was partially generated by patch-package.
We could make docs much better (and promote project):
README.md
.const
problem).an innocent file like this:
var x
x.values()
Will fail eslint with this error:
ES6 methods not allowed: values es5/no-es6-methods
This is my .eslintrc
file:
{
"extends": [
"plugin:es5/no-es2015"
]
}
In short, I think there's no easy way to tell if x
(in the example above) is an array or something that really does have .values()
- so I propose that we drop these rules... WDYT?
This code fails in 1.4.0, but passes in 1.3.x
Foo.prototype.toString = function toString(){...}
Cursory glance, it looks like this commit might be the culprit: 84504e7#diff-fc9d2adbd42af3a2b5385af5ab88241a
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.