eslint-plugin-chai-friendly 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,26 +1,31 @@
1
1
  # eslint-plugin-chai-friendly
2
2
 
3
- This plugin overrides `no-unused-expressions` to make it friendly towards chai expect statements.
3
+ [![npm](https://img.shields.io/npm/v/eslint-plugin-chai-friendly.svg)](https://www.npmjs.com/package/eslint-plugin-chai-friendly) [![npm](https://img.shields.io/npm/dm/eslint-plugin-chai-friendly.svg)](https://www.npmjs.com/package/eslint-plugin-chai-friendly)
4
+
5
+ This plugin overrides `no-unused-expressions` to make it friendly towards chai `expect` and `should` statements.
6
+
4
7
  ```javascript
5
8
  // this
6
9
  expect(foo).to.be.true;
10
+ foo.should.be.true;
7
11
 
8
12
  // instead of this
9
13
  expect(foo).to.be.true; // eslint-disable-line no-unused-expressions
14
+ foo.should.be.true; // eslint-disable-line no-unused-expressions
10
15
  ```
11
16
 
12
17
  ## Installation
13
18
 
14
19
  You'll first need to install [ESLint](http://eslint.org):
15
20
 
16
- ```
17
- $ npm i eslint --save-dev
21
+ ```bash
22
+ npm i eslint --save-dev
18
23
  ```
19
24
 
20
25
  Next, install `eslint-plugin-chai-friendly`:
21
26
 
22
- ```
23
- $ npm install eslint-plugin-chai-friendly --save-dev
27
+ ```bash
28
+ npm install eslint-plugin-chai-friendly --save-dev
24
29
  ```
25
30
 
26
31
  **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-chai-friendly` globally.
@@ -49,11 +54,18 @@ Then disable original `no-unused-expressions` rule and configure chai-friendly r
49
54
  }
50
55
  ```
51
56
 
52
- ## Supported Rules
57
+ ## Options
53
58
 
54
- * chai-friendly/no-unused-expressions
59
+ This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:
55
60
 
61
+ - `allowShortCircuit` set to `true` will allow you to use short circuit evaluations in your expressions (Default: `false`).
62
+ - `allowTernary` set to `true` will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: `false`).
63
+ - `allowTaggedTemplates` set to `true` will enable you to use tagged template literals in your expressions (Default: `false`).
56
64
 
65
+ These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).
57
66
 
67
+ More info in the original rule's [docs](http://eslint.org/docs/rules/no-unused-expressions#options).
58
68
 
69
+ ## Supported Rules
59
70
 
71
+ - chai-friendly/no-unused-expressions
@@ -26,6 +26,9 @@ module.exports = {
26
26
  },
27
27
  allowTernary: {
28
28
  type: "boolean"
29
+ },
30
+ allowTaggedTemplates: {
31
+ type: "boolean"
29
32
  }
30
33
  },
31
34
  additionalProperties: false
@@ -35,7 +38,9 @@ module.exports = {
35
38
  create: function (context) {
36
39
  var config = context.options[0] || {},
37
40
  allowShortCircuit = config.allowShortCircuit || false,
38
- allowTernary = config.allowTernary || false;
41
+ allowTernary = config.allowTernary || false,
42
+ allowTaggedTemplates = config.allowTaggedTemplates || false;
43
+
39
44
 
40
45
  /**
41
46
  * @param {ASTNode} node - any node
@@ -101,6 +106,10 @@ module.exports = {
101
106
  }
102
107
  }
103
108
 
109
+ if (allowTaggedTemplates && node.type === "TaggedTemplateExpression") {
110
+ return true;
111
+ }
112
+
104
113
  return /^(?:Assignment|Call|New|Update|Yield|Await)Expression$/.test(node.type) ||
105
114
  (node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0);
106
115
  }
@@ -111,7 +120,7 @@ module.exports = {
111
120
  * @param {ASTNode} node - any node
112
121
  * @returns {boolean} whether the given node is a chai expectation
113
122
  */
114
- function isChaiExpectation(node) {
123
+ function isChaiExpectCall(node) {
115
124
  var expression = node.expression;
116
125
  if (expression.type !== 'MemberExpression') {
117
126
  return false;
@@ -145,10 +154,54 @@ module.exports = {
145
154
  return null;
146
155
  };
147
156
 
157
+ /**
158
+ * Determines whether or not a given node is a chai's should statement.
159
+ * e.g. foo.should.eventually.be.true;
160
+ * @param {ASTNode} node - any node
161
+ * @returns {boolean} whether the given node is a chai should statement
162
+ */
163
+ function isChaiShouldCall(node) {
164
+ var expression = node.expression;
165
+ if (expression.type !== 'MemberExpression') {
166
+ return false;
167
+ }
168
+
169
+ var hasShouldCall = Boolean(findShouldCall(expression.object));
170
+
171
+ return hasShouldCall;
172
+ }
173
+
174
+ /**
175
+ * Searches for the chai obj.should call down the AST.
176
+ * @param {ASTNode} node - any node
177
+ * @returns {ASTNode} obj.should call expression or null
178
+ */
179
+ function findShouldCall(node) {
180
+ // Found obj.should call, return the node
181
+ if (node.type === 'MemberExpression' && node.property && node.property.name === 'should') {
182
+ return node;
183
+ }
184
+
185
+ // Continue search up the AST if it's a member call
186
+ if (node.type === 'MemberExpression') {
187
+ return findShouldCall(node.object);
188
+ }
189
+ if (node.type === 'CallExpression') {
190
+ return findShouldCall(node.callee);
191
+ }
192
+
193
+ // Stop search, obj.should not found
194
+ return null;
195
+ };
196
+
148
197
 
149
198
  return {
150
199
  ExpressionStatement: function(node) {
151
- if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors()) && !isChaiExpectation(node)) {
200
+ var valid = isValidExpression(node.expression)
201
+ || isDirective(node, context.getAncestors())
202
+ || isChaiExpectCall(node)
203
+ || isChaiShouldCall(node);
204
+ if (!valid) {
152
205
  context.report(node, "Expected an assignment or function call and instead saw an expression.");
153
206
  }
154
207
  }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @fileoverview Flag expressions in statement position that do not side effect
3
+ * @author Michael Ficarra
4
+ */
5
+ "use strict";
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Rule Definition
9
+ //------------------------------------------------------------------------------
10
+
11
+ module.exports = {
12
+ meta: {
13
+ docs: {
14
+ description: "disallow unused expressions",
15
+ category: "Best Practices",
16
+ recommended: false
17
+ },
18
+
19
+ schema: [
20
+ {
21
+ type: "object",
22
+ properties: {
23
+ allowShortCircuit: {
24
+ type: "boolean"
25
+ },
26
+ allowTernary: {
27
+ type: "boolean"
28
+ },
29
+ allowTaggedTemplates: {
30
+ type: "boolean"
31
+ }
32
+ },
33
+ additionalProperties: false
34
+ }
35
+ ]
36
+ },
37
+
38
+ create(context) {
39
+ const config = context.options[0] || {},
40
+ allowShortCircuit = config.allowShortCircuit || false,
41
+ allowTernary = config.allowTernary || false,
42
+ allowTaggedTemplates = config.allowTaggedTemplates || false;
43
+
44
+ /**
45
+ * @param {ASTNode} node - any node
46
+ * @returns {boolean} whether the given node structurally represents a directive
47
+ */
48
+ function looksLikeDirective(node) {
49
+ return node.type === "ExpressionStatement" &&
50
+ node.expression.type === "Literal" && typeof node.expression.value === "string";
51
+ }
52
+
53
+ /**
54
+ * @param {Function} predicate - ([a] -> Boolean) the function used to make the determination
55
+ * @param {a[]} list - the input list
56
+ * @returns {a[]} the leading sequence of members in the given list that pass the given predicate
57
+ */
58
+ function takeWhile(predicate, list) {
59
+ for (let i = 0; i < list.length; ++i) {
60
+ if (!predicate(list[i])) {
61
+ return list.slice(0, i);
62
+ }
63
+ }
64
+ return list.slice();
65
+ }
66
+
67
+ /**
68
+ * @param {ASTNode} node - a Program or BlockStatement node
69
+ * @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
70
+ */
71
+ function directives(node) {
72
+ return takeWhile(looksLikeDirective, node.body);
73
+ }
74
+
75
+ /**
76
+ * @param {ASTNode} node - any node
77
+ * @param {ASTNode[]} ancestors - the given node's ancestors
78
+ * @returns {boolean} whether the given node is considered a directive in its current position
79
+ */
80
+ function isDirective(node, ancestors) {
81
+ const parent = ancestors[ancestors.length - 1],
82
+ grandparent = ancestors[ancestors.length - 2];
83
+
84
+ return (parent.type === "Program" || parent.type === "BlockStatement" &&
85
+ (/Function/.test(grandparent.type))) &&
86
+ directives(parent).indexOf(node) >= 0;
87
+ }
88
+
89
+ /**
90
+ * Determines whether or not a given node is a valid expression. Recurses on short circuit eval and ternary nodes if enabled by flags.
91
+ * @param {ASTNode} node - any node
92
+ * @returns {boolean} whether the given node is a valid expression
93
+ */
94
+ function isValidExpression(node) {
95
+ if (allowTernary) {
96
+
97
+ // Recursive check for ternary and logical expressions
98
+ if (node.type === "ConditionalExpression") {
99
+ return isValidExpression(node.consequent) && isValidExpression(node.alternate);
100
+ }
101
+ }
102
+
103
+ if (allowShortCircuit) {
104
+ if (node.type === "LogicalExpression") {
105
+ return isValidExpression(node.right);
106
+ }
107
+ }
108
+
109
+ if (allowTaggedTemplates && node.type === "TaggedTemplateExpression") {
110
+ return true;
111
+ }
112
+
113
+ return /^(?:Assignment|Call|New|Update|Yield|Await)Expression$/.test(node.type) ||
114
+ (node.type === "UnaryExpression" && ["delete", "void"].indexOf(node.operator) >= 0);
115
+ }
116
+
117
+ return {
118
+ ExpressionStatement(node) {
119
+ if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) {
120
+ context.report({ node, message: "Expected an assignment or function call and instead saw an expression." });
121
+ }
122
+ }
123
+ };
124
+
125
+ }
126
+ };
package/package.json CHANGED
@@ -1,66 +1,7 @@
1
1
  {
2
- "_args": [
3
- [
4
- "eslint-plugin-chai-friendly",
5
- "/Users/user/repos/wallet-sdk"
6
- ],
7
- [
8
- "eslint-plugin-chai-friendly",
9
- "/Users/user/repos/stellar-wallet-js-sdk"
10
- ]
11
- ],
12
- "_from": "eslint-plugin-chai-friendly@latest",
13
- "_id": "eslint-plugin-chai-friendly@0.3.3",
14
- "_inCache": true,
15
- "_installable": true,
16
- "_location": "/eslint-plugin-chai-friendly",
17
- "_nodeVersion": "6.0.0",
18
- "_npmOperationalInternal": {
19
- "host": "packages-12-west.internal.npmjs.com",
20
- "tmp": "tmp/eslint-plugin-chai-friendly-0.3.3.tgz_1492420383674_0.6659231542143971"
21
- },
22
- "_npmUser": {
23
- "email": "ih.diachenko@gmail.com",
24
- "name": "ihor.diachenko"
25
- },
26
- "_npmVersion": "3.8.6",
27
- "_phantomChildren": {},
28
- "_requested": {
29
- "name": "eslint-plugin-chai-friendly",
30
- "raw": "eslint-plugin-chai-friendly",
31
- "rawSpec": "",
32
- "scope": null,
33
- "spec": "latest",
34
- "type": "tag"
35
- },
36
- "_requiredBy": [
37
- "#USER"
38
- ],
39
- "_shrinkwrap": null,
40
- "_spec": "eslint-plugin-chai-friendly",
41
- "_where": "/Users/user/repos/stellar-wallet-js-sdk",
42
- "author": {
43
- "name": "Ihor Diachenko"
44
- },
45
- "bugs": {
46
- "url": "https://github.com/ihordiachenko/eslint-plugin-chai-friendly/issues"
47
- },
48
- "dependencies": {},
2
+ "name": "eslint-plugin-chai-friendly",
3
+ "version": "0.4.1",
49
4
  "description": "This plugin makes 'no-unused-expressions' rule friendly towards chai expect statements.",
50
- "devDependencies": {
51
- "eslint": "~3.11.0",
52
- "mocha": "^3.0.2"
53
- },
54
- "directories": {},
55
- "dist": {
56
- "shasum": "17ac9e0f53e50f09aa0d18db9eb8998df7b47f96",
57
- "tarball": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.3.3.tgz"
58
- },
59
- "engines": {
60
- "node": ">=0.10.0"
61
- },
62
- "gitHead": "c1cf0b8c37b8d1aa1e6ec5e45ef57f98d30c12be",
63
- "homepage": "https: //github.com/ihordiachenko/eslint-plugin-chai-friendly#readme",
64
5
  "keywords": [
65
6
  "eslint",
66
7
  "eslintplugin",
@@ -68,26 +9,29 @@
68
9
  "chai",
69
10
  "lint"
70
11
  ],
71
- "license": "MIT",
72
- "main": "lib/index.js",
73
- "maintainers": [
74
- {
75
- "email": "ih.diachenko@gmail.com",
76
- "name": "ihor.diachenko"
77
- }
78
- ],
79
- "name": "eslint-plugin-chai-friendly",
80
- "optionalDependencies": {},
81
- "peerDependencies": {
82
- "eslint": ">=3.0.0"
83
- },
84
- "readme": "ERROR: No README data found!",
85
12
  "repository": {
86
13
  "type": "git",
87
14
  "url": "git+https://github.com/ihordiachenko/eslint-plugin-chai-friendly.git"
88
15
  },
16
+ "homepage": "https://github.com/ihordiachenko/eslint-plugin-chai-friendly#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/ihordiachenko/eslint-plugin-chai-friendly/issues"
19
+ },
20
+ "author": "Ihor Diachenko",
21
+ "main": "lib/index.js",
89
22
  "scripts": {
90
23
  "test": "mocha tests --recursive"
91
24
  },
92
- "version": "0.3.4"
25
+ "dependencies": {},
26
+ "peerDependencies": {
27
+ "eslint": ">=3.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "eslint": "~3.11.0",
31
+ "mocha": "^3.0.2"
32
+ },
33
+ "engines": {
34
+ "node": ">=0.10.0"
35
+ },
36
+ "license": "MIT"
93
37
  }
@@ -27,16 +27,16 @@ ruleTester.run("no-unused-expressions", rule, {
27
27
  "f(); g()",
28
28
  "i++",
29
29
  "a()",
30
- { code: "a && a()", options: [{ allowShortCircuit: true }] },
31
- { code: "a() || (b = c)", options: [{ allowShortCircuit: true }] },
32
- { code: "a ? b() : c()", options: [{ allowTernary: true }] },
33
- { code: "a ? b() || (c = d) : e()", options: [{ allowShortCircuit: true, allowTernary: true }] },
30
+ { code: "a && a()", options: [{ allowShortCircuit: true }]},
31
+ { code: "a() || (b = c)", options: [{ allowShortCircuit: true }]},
32
+ { code: "a ? b() : c()", options: [{ allowTernary: true }]},
33
+ { code: "a ? b() || (c = d) : e()", options: [{ allowShortCircuit: true, allowTernary: true }]},
34
34
  "delete foo.bar",
35
35
  "void new C",
36
36
  "\"use strict\";",
37
37
  "\"directive one\"; \"directive two\"; f();",
38
38
  "function foo() {\"use strict\"; return true; }",
39
- { code: "var foo = () => {\"use strict\"; return true; }", parserOptions: { ecmaVersion: 6 } },
39
+ { code: "var foo = () => {\"use strict\"; return true; }", parserOptions: { ecmaVersion: 6 }},
40
40
  "function foo() {\"directive one\"; \"directive two\"; f(); }",
41
41
  "function foo() { var foo = \"use strict\"; return true; }",
42
42
  {
@@ -61,33 +61,77 @@ ruleTester.run("no-unused-expressions", rule, {
61
61
  options: [{ allowTernary: true }],
62
62
  parserOptions: { ecmaVersion: 8 }
63
63
  },
64
- "expect(foo).to.be.ok",
65
- "expect(foo).be.ok",
66
- "expect(foo).to.eventually().be.ok"
64
+ {
65
+ code: "tag`tagged template literal`",
66
+ options: [{ allowTaggedTemplates: true }],
67
+ parserOptions: { ecmaVersion: 6 }
68
+ },
69
+ {
70
+ code: "shouldNotBeAffectedByAllowTemplateTagsOption()",
71
+ options: [{ allowTaggedTemplates: true }],
72
+ parserOptions: { ecmaVersion: 6 }
73
+ },
74
+ // Chai statements
75
+ "expect(foo).to.be.true;",
76
+ "expect(foo).to.have.a.property('bar').which.is.true",
77
+ "foo.should.be.true;",
78
+ "foo.inner.nested.should.be.true",
79
+ "foo.should.have.a.property('bar').which.is.true;"
67
80
  ],
68
81
  invalid: [
69
- { code: "0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
70
- { code: "a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
71
- { code: "f(), 0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
72
- { code: "{0}", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
73
- { code: "[]", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
74
- { code: "a && b();", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
75
- { code: "a() || false", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] },
76
- { code: "a || (b = c)", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] },
77
- { code: "a ? b() || (c = d) : e", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] },
82
+ { code: "0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
83
+ { code: "a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
84
+ { code: "f(), 0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
85
+ { code: "{0}", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
86
+ { code: "[]", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
87
+ { code: "a && b();", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
88
+ { code: "a() || false", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }]},
89
+ { code: "a || (b = c)", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }]},
90
+ { code: "a ? b() || (c = d) : e", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }]},
78
91
  { code: "a && b()", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }]},
79
92
  { code: "a ? b() : c()", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }]},
80
- { code: "a || b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
81
- { code: "a() && b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
82
- { code: "a ? b : 0", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
83
- { code: "a ? b : c()", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
84
- { code: "foo.bar;", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
85
- { code: "!a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
86
- { code: "+a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
87
- { code: "\"directive one\"; f(); \"directive two\";", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
88
- { code: "function foo() {\"directive one\"; f(); \"directive two\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
89
- { code: "if (0) { \"not a directive\"; f(); }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
90
- { code: "function foo() { var foo = true; \"use strict\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] },
91
- { code: "var foo = () => { var foo = true; \"use strict\"; }", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}] }
93
+ { code: "a || b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
94
+ { code: "a() && b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
95
+ { code: "a ? b : 0", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
96
+ { code: "a ? b : c()", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
97
+ { code: "foo.bar;", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
98
+ { code: "!a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
99
+ { code: "+a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
100
+ { code: "\"directive one\"; f(); \"directive two\";", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
101
+ { code: "function foo() {\"directive one\"; f(); \"directive two\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
102
+ { code: "if (0) { \"not a directive\"; f(); }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
103
+ { code: "function foo() { var foo = true; \"use strict\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
104
+ { code: "var foo = () => { var foo = true; \"use strict\"; }", parserOptions: { ecmaVersion: 6}, errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
105
+ {
106
+ code: "`untagged template literal`",
107
+ options: [{ allowTaggedTemplates: true }],
108
+ parserOptions: { ecmaVersion: 6},
109
+ errors: ["Expected an assignment or function call and instead saw an expression."]
110
+ },
111
+ {
112
+ code: "`untagged template literal`",
113
+ options: [{ allowTaggedTemplates: false }],
114
+ parserOptions: { ecmaVersion: 6},
115
+ errors: ["Expected an assignment or function call and instead saw an expression."]
116
+ },
117
+ {
118
+ code: "tag`tagged template literal`",
119
+ options: [{ allowTaggedTemplates: false }],
120
+ parserOptions: { ecmaVersion: 6},
121
+ errors: ["Expected an assignment or function call and instead saw an expression."]
122
+ },
123
+ {
124
+ code: "`untagged template literal`",
125
+ parserOptions: { ecmaVersion: 6 },
126
+ errors: ["Expected an assignment or function call and instead saw an expression."]
127
+ },
128
+ {
129
+ code: "tag`tagged template literal`",
130
+ parserOptions: { ecmaVersion: 6 },
131
+ errors: ["Expected an assignment or function call and instead saw an expression."]
132
+ },
133
+ // Chai statements
134
+ { code: "foo.expect('bar').not.to.pass;", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }]},
135
+ { code: "should.not.pass;", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement" }] },
92
136
  ]
93
137
  });
package/.npmignore DELETED
@@ -1 +0,0 @@
1
- ./tests