Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-babel

Package Overview
Dependencies
Maintainers
11
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-babel - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

rules/no-unused-expressions.js

2

index.js

@@ -17,2 +17,3 @@ 'use strict';

'semi': require('./rules/semi'),
'no-unused-expressions': require('./rules/no-unused-expressions'),
},

@@ -32,3 +33,4 @@ rulesConfig: {

'semi': 0,
'no-unused-expressions': 0,
}
};

4

package.json
{
"name": "eslint-plugin-babel",
"version": "5.0.0",
"version": "5.1.0",
"description": "an eslint rule plugin companion to babel-eslint",

@@ -33,3 +33,3 @@ "main": "index.js",

"dependencies": {
"eslint-rule-composer": "^0.1.1"
"eslint-rule-composer": "^0.3.0"
},

@@ -36,0 +36,0 @@ "devDependencies": {

@@ -35,3 +35,4 @@ # eslint-plugin-babel

"babel/quotes": 1,
"babel/semi": 1
"babel/semi": 1,
"babel/no-unused-expressions": 1
}

@@ -51,2 +52,3 @@ }

- `babel/semi`: doesn't fail when using `for await (let something of {})`. Includes class properties (🛠)
- `babel/no-unused-expressions`: doesn't fail when using `do` expressions

@@ -53,0 +55,0 @@ #### Deprecated

@@ -86,7 +86,7 @@ "use strict";

if (!isSemicolon(lastToken)) {
if (!exceptOneLine || !isOneLinerBlock(node)) {
if (!exceptOneLine || !isOneLinerBlock(context, node)) {
report(context, node);
}
} else {
if (exceptOneLine && isOneLinerBlock(node)) {
if (exceptOneLine && isOneLinerBlock(context, node)) {
report(context, node, true);

@@ -93,0 +93,0 @@ }

@@ -40,12 +40,15 @@ /* eslint-disable */

"var x = $();",
{ code: "var x = Foo(42)", options: [{"capIsNew": false}] },
{ code: "var x = bar.Foo(42)", options: [{"capIsNew": false}] },
{ code: "var x = Foo(42)", options: [{ capIsNew: false }] },
{ code: "var x = bar.Foo(42)", options: [{ capIsNew: false }] },
{ code: "var x = Foo.bar(42)", options: [{ capIsNew: false }] },
"var x = bar[Foo](42)",
{code: "var x = bar['Foo'](42)", options: [{"capIsNew": false}] },
{ code: "var x = bar['Foo'](42)", options: [{ capIsNew: false }] },
"var x = Foo.bar(42)",
{ code: "var x = new foo(42)", options: [{"newIsCap": false}] },
{ code: "var x = new foo(42)", options: [{ newIsCap: false }] },
"var o = { 1: function() {} }; o[1]();",
"var o = { 1: function() {} }; new o[1]();",
{ code: "var x = Foo(42);", options: [{ capIsNew: true, capIsNewExceptions: ["Foo"] }] },
{ code: "var x = Foo(42);", options: [{ capIsNewExceptionPattern: "^Foo" }] },
{ code: "var x = new foo(42);", options: [{ newIsCap: true, newIsCapExceptions: ["foo"] }] },
{ code: "var x = new foo(42);", options: [{ newIsCapExceptionPattern: "^foo" }] },
{ code: "var x = Object(42);", options: [{ capIsNewExceptions: ["Foo"] }] },

@@ -55,5 +58,12 @@

{ code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptions: ["Foo.Bar"] }] },
{ code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptionPattern: "^Foo\\.." }] },
{ code: "var x = new foo.bar(42);", options: [{ newIsCapExceptions: ["bar"] }] },
{ code: "var x = new foo.bar(42);", options: [{ newIsCapExceptions: ["foo.bar"] }] },
{ code: "var x = new foo.bar(42);", options: [{ newIsCapExceptionPattern: "^foo\\.." }] },
{ code: "var x = new foo.bar(42);", options: [{ properties: false }] },
{ code: "var x = Foo.bar(42);", options: [{ properties: false }] },
{ code: "var x = foo.Bar(42);", options: [{ capIsNew: false, properties: false }] },
// Babel-specific test cases.

@@ -63,11 +73,11 @@ { code: "@MyDecorator(123) class MyClass{}", parser: "babel-eslint" },

invalid: [
{ code: "var x = new c();", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression"}] },
{ code: "var x = new φ;", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression"}] },
{ code: "var x = new a.b.c;", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression"}] },
{ code: "var x = new a.b['c'];", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression"}] },
{ code: "var b = Foo();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression"}] },
{ code: "var b = a.Foo();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression"}] },
{ code: "var b = a['Foo']();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression"}] },
{ code: "var b = a.Date.UTC();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression"}] },
{ code: "var b = UTC();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression"}] },
{ code: "var x = new c();", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] },
{ code: "var x = new φ;", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] },
{ code: "var x = new a.b.c;", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] },
{ code: "var x = new a.b['c'];", errors: [{ message: "A constructor name should not start with a lowercase letter.", type: "NewExpression" }] },
{ code: "var b = Foo();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] },
{ code: "var b = a.Foo();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] },
{ code: "var b = a['Foo']();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] },
{ code: "var b = a.Date.UTC();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] },
{ code: "var b = UTC();", errors: [{ message: "A function with a name starting with an uppercase letter should only be used as a constructor.", type: "CallExpression" }] },
{

@@ -131,11 +141,23 @@ code: "var a = B.C();",

code: "var x = Foo.Bar(42);",
options: [{capIsNewExceptions: ["Foo"]}],
errors: [{type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor."}]
options: [{ capIsNewExceptions: ["Foo"] }],
errors: [{ type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor." }]
},
{
code: "var x = Bar.Foo(42);",
options: [{ capIsNewExceptionPattern: "^Foo\\.." }],
errors: [{ type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor." }]
},
{
code: "var x = new foo.bar(42);",
options: [{newIsCapExceptions: ["foo"]}],
errors: [{type: "NewExpression", message: "A constructor name should not start with a lowercase letter."}]
options: [{ newIsCapExceptions: ["foo"] }],
errors: [{ type: "NewExpression", message: "A constructor name should not start with a lowercase letter." }]
},
{
code: "var x = new bar.foo(42);",
options: [{ newIsCapExceptionPattern: "^foo\\.." }],
errors: [{ type: "NewExpression", message: "A constructor name should not start with a lowercase letter." }]
}
]
});

@@ -106,6 +106,8 @@ /* eslnit-disable */

{ code: "async function foo() { for await (let thing of {}) { console.log(thing); } }", parserOptions: { ecmaVersion: 6 } },
{ code: "class Foo { bar = () => {}; }", options: ["always", { omitLastInOneLineBlock: true }] },
// babel, "never"
{ code: "class Foo { bar = 'example' }", options: ["never"] },
{ code: "class Foo { static bar = 'example' }", options: ["never"] }
{ code: "class Foo { static bar = 'example' }", options: ["never"] },
{ code: "class Foo { bar = () => {} }", options: ["never"] },
],

@@ -188,7 +190,17 @@ invalid: [

{ code: "class Foo { static bar = 'example' }", errors: [{ message: "Missing semicolon." }] },
{
code: "class Foo { bar = () => {} }",
options: ["always", { omitLastInOneLineBlock: true }],
errors: [{ message: "Missing semicolon." }]
},
// babel, "never"
{ code: "class Foo { bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] },
{ code: "class Foo { static bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] }
{ code: "class Foo { static bar = 'example'; }", options: ["never"], errors: [{ message: "Extra semicolon." }] },
{
code: "class Foo { bar = () => {}; }",
options: ["never"],
errors: [{ message: "Extra semicolon." }]
},
]
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc