Code Monkey home page Code Monkey logo

eslint-plugin-es5's Issues

Target specific presets

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.

Add rule/option for only allowing `let` declarations in `for ... in` for IE11

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!

Does not catch Async/Await

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!

const and let is still allowed

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)

1.5 release changes

The project has no ChangeLog.md and Releases miss 1.4 and 1.5. What were features of that 2 releases?

Send PR to airbnb ES5 config

I think it will be good promotion for project.

Don’t forget to:

  1. Describe why it is important for AirBnB. Like ES6 features could broke JS.
  2. Mention developers who often accept PRs in repo, so they will be noticed about PR by email.

no-es6-methods rule should have an "exceptMethods" option

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.

Better docs

We could make docs much better (and promote project):

  • Add rules list to README.md.
  • Add examples, why ES6 code could broke your production (like Safari and const problem).

no-es6-methods a bit too strict

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.