eslint-plugin-chai-friendly 0.7.4 → 0.8.0

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
@@ -32,31 +32,52 @@ npm install eslint-plugin-chai-friendly --save-dev
32
32
 
33
33
  ## Usage
34
34
 
35
- Add `chai-friendly` to the plugins section of your `.eslintrc.*` configuration file. You can omit the `eslint-plugin-` prefix:
35
+ Add `chai-friendly` to the plugins section of your ESLint configuration file. Then disable original `no-unused-expressions` rule and configure chai-friendly replacement under the rules section.
36
36
 
37
- ```json
38
- {
39
- "plugins": [
40
- "chai-friendly"
41
- ]
42
- }
43
- ```
37
+ ESLint 9 flat config format:
38
+
39
+ ```js
40
+ import pluginChaiFriendly from 'eslint-plugin-chai-friendly';
44
41
 
42
+ export default {
43
+ plugins: {'chai-friendly': pluginChaiFriendly},
44
+ rules: {
45
+ "no-unused-expressions": "off", // disable original rule
46
+ "chai-friendly/no-unused-expressions": "error"
47
+ },
48
+ };
49
+ ```
45
50
 
46
- Then disable original `no-unused-expressions` rule and configure chai-friendly replacement under the rules section.
51
+ Legacy `.eslintrc` format:
47
52
 
48
53
  ```json
49
54
  {
55
+ "plugins": [
56
+ "chai-friendly" // you can omit the eslint-plugin- prefix
57
+ ],
50
58
  "rules": {
51
- "no-unused-expressions": 0,
59
+ "no-unused-expressions": 0, // disable original rule
52
60
  "chai-friendly/no-unused-expressions": 2
53
61
  }
54
62
  }
55
63
  ```
56
64
 
57
65
  If you don't need to tweak the above rule settings, you can instead
58
- just add the following to your config file's `extends` and the above
59
- will be applied automatically:
66
+ extend the provided recommended configuration.
67
+
68
+ ESLint 9 flat config format:
69
+
70
+ ```js
71
+ const pluginChaiFriendly = require("eslint-plugin-chai-friendly");
72
+
73
+ module.exports = [
74
+ pluginChaiFriendly.configs.recommended,
75
+ // other configurations
76
+ ]
77
+ ```
78
+
79
+ Legacy `.eslintrc` format:
80
+
60
81
 
61
82
  ```json
62
83
  {
package/lib/index.js CHANGED
@@ -3,17 +3,31 @@
3
3
  * @author Ihor Diachenko
4
4
  */
5
5
 
6
- module.exports = {
7
- configs: {
8
- recommended: {
9
- plugins: ['chai-friendly'],
10
- rules: {
11
- 'chai-friendly/no-unused-expressions': 'error',
12
- 'no-unused-expressions': 'off'
13
- }
14
- }
6
+ const pjs = require('../package.json');
7
+
8
+ const plugin = {
9
+ meta: {
10
+ name: pjs.name,
11
+ version: pjs.version,
15
12
  },
16
13
  rules: {
17
14
  'no-unused-expressions': require('./rules/no-unused-expressions')
18
- }
15
+ },
16
+ processors: {},
17
+ configs: {}
19
18
  };
19
+
20
+ // assign configs here so we can reference `plugin`
21
+ Object.assign(plugin.configs, {
22
+ recommended: {
23
+ plugins: {
24
+ 'chai-friendly': plugin
25
+ },
26
+ rules: {
27
+ 'chai-friendly/no-unused-expressions': 'error',
28
+ 'no-unused-expressions': 'off'
29
+ }
30
+ }
31
+ },)
32
+
33
+ module.exports = plugin;
@@ -255,11 +255,15 @@ module.exports = {
255
255
  return null;
256
256
  }
257
257
 
258
-
258
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
259
259
  return {
260
260
  ExpressionStatement: function(node) {
261
261
  var valid = !Checker.isDisallowed(node.expression)
262
- || isDirective(node, context.getAncestors())
262
+ || isDirective(node,
263
+ (sourceCode.getAncestors
264
+ ? sourceCode.getAncestors(node)
265
+ : context.getAncestors()
266
+ ))
263
267
  || isChaiExpectCall(node)
264
268
  || isChaiShouldCall(node);
265
269
  if (!valid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-chai-friendly",
3
- "version": "0.7.4",
3
+ "version": "0.8.0",
4
4
  "description": "This plugin makes 'no-unused-expressions' rule friendly towards chai expect statements.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -22,9 +22,13 @@
22
22
  "Brett Zamir"
23
23
  ],
24
24
  "main": "lib/index.js",
25
+ "files": [
26
+ "lib/**/*.js"
27
+ ],
25
28
  "scripts": {
26
29
  "lint": "eslint .",
27
- "test": "nyc mocha tests --recursive"
30
+ "test": "nyc mocha tests --recursive",
31
+ "integration-test": "npx eslint examples/test.js --no-ignore"
28
32
  },
29
33
  "peerDependencies": {
30
34
  "eslint": ">=3.0.0"
@@ -32,7 +36,8 @@
32
36
  "devDependencies": {
33
37
  "@babel/core": "^7.23.7",
34
38
  "@babel/eslint-parser": "^7.23.3",
35
- "eslint": "^8.56.0",
39
+ "chai": "^5.1.1",
40
+ "eslint": "^9.3.0",
36
41
  "mocha": "^10.0.0",
37
42
  "nyc": "^15.1.0"
38
43
  },
package/.editorconfig DELETED
@@ -1,15 +0,0 @@
1
- ; EditorConfig file: https://EditorConfig.org
2
- ; Install the "EditorConfig" plugin into your editor to use
3
-
4
- root = true
5
-
6
- [*]
7
- charset = utf-8
8
- end_of_line = lf
9
- insert_final_newline = true
10
- indent_style = space
11
- indent_size = 4
12
- trim_trailing_whitespace = true
13
-
14
- [*.json]
15
- indent_size = 2
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- !.eslintrc.js
package/.eslintrc.js DELETED
@@ -1,18 +0,0 @@
1
- module.exports = {
2
- parser: "@babel/eslint-parser",
3
- parserOptions: {
4
- requireConfigFile: false,
5
- babelOptions: {
6
- babelrc: false,
7
- configFile: false,
8
- },
9
- },
10
- extends: ['eslint:recommended'],
11
- env: {
12
- node: true
13
- },
14
- rules: {
15
- strict: ['error'],
16
- indent: ['error', 4]
17
- }
18
- };
@@ -1 +0,0 @@
1
- {"/Users/user/repos/eslint-plugin-chai-friendly/lib/rules/no-unused-expressions.js":{"path":"/Users/user/repos/eslint-plugin-chai-friendly/lib/rules/no-unused-expressions.js","statementMap":{"0":{"start":{"line":16,"column":4},"end":{"line":16,"column":16}},"1":{"start":{"line":24,"column":4},"end":{"line":24,"column":17}},"2":{"start":{"line":28,"column":0},"end":{"line":271,"column":2}},"3":{"start":{"line":65,"column":21},"end":{"line":65,"column":45}},"4":{"start":{"line":66,"column":32},"end":{"line":66,"column":65}},"5":{"start":{"line":67,"column":27},"end":{"line":67,"column":55}},"6":{"start":{"line":68,"column":35},"end":{"line":68,"column":71}},"7":{"start":{"line":69,"column":28},"end":{"line":69,"column":57}},"8":{"start":{"line":76,"column":12},"end":{"line":77,"column":96}},"9":{"start":{"line":86,"column":12},"end":{"line":90,"column":13}},"10":{"start":{"line":86,"column":25},"end":{"line":86,"column":26}},"11":{"start":{"line":87,"column":16},"end":{"line":89,"column":17}},"12":{"start":{"line":88,"column":20},"end":{"line":88,"column":44}},"13":{"start":{"line":91,"column":12},"end":{"line":91,"column":32}},"14":{"start":{"line":99,"column":12},"end":{"line":99,"column":60}},"15":{"start":{"line":108,"column":25},"end":{"line":108,"column":56}},"16":{"start":{"line":109,"column":30},"end":{"line":109,"column":61}},"17":{"start":{"line":117,"column":12},"end":{"line":119,"column":58}},"18":{"start":{"line":126,"column":24},"end":{"line":171,"column":10}},"19":{"start":{"line":128,"column":16},"end":{"line":128,"column":65}},"20":{"start":{"line":135,"column":16},"end":{"line":135,"column":61}},"21":{"start":{"line":139,"column":16},"end":{"line":141,"column":17}},"22":{"start":{"line":140,"column":20},"end":{"line":140,"column":105}},"23":{"start":{"line":142,"column":16},"end":{"line":142,"column":28}},"24":{"start":{"line":148,"column":16},"end":{"line":148,"column":37}},"25":{"start":{"line":151,"column":16},"end":{"line":151,"column":37}},"26":{"start":{"line":154,"column":16},"end":{"line":156,"column":17}},"27":{"start":{"line":155,"column":20},"end":{"line":155,"column":60}},"28":{"start":{"line":157,"column":16},"end":{"line":157,"column":28}},"29":{"start":{"line":164,"column":16},"end":{"line":164,"column":45}},"30":{"start":{"line":169,"column":16},"end":{"line":169,"column":78}},"31":{"start":{"line":180,"column":29},"end":{"line":180,"column":44}},"32":{"start":{"line":181,"column":12},"end":{"line":183,"column":13}},"33":{"start":{"line":182,"column":16},"end":{"line":182,"column":29}},"34":{"start":{"line":185,"column":12},"end":{"line":185,"column":62}},"35":{"start":{"line":195,"column":12},"end":{"line":197,"column":13}},"36":{"start":{"line":196,"column":16},"end":{"line":196,"column":28}},"37":{"start":{"line":200,"column":12},"end":{"line":202,"column":13}},"38":{"start":{"line":201,"column":16},"end":{"line":201,"column":51}},"39":{"start":{"line":203,"column":12},"end":{"line":205,"column":13}},"40":{"start":{"line":204,"column":16},"end":{"line":204,"column":51}},"41":{"start":{"line":206,"column":12},"end":{"line":208,"column":13}},"42":{"start":{"line":207,"column":16},"end":{"line":207,"column":55}},"43":{"start":{"line":211,"column":12},"end":{"line":211,"column":24}},"44":{"start":{"line":221,"column":29},"end":{"line":221,"column":44}},"45":{"start":{"line":222,"column":12},"end":{"line":224,"column":13}},"46":{"start":{"line":223,"column":16},"end":{"line":223,"column":50}},"47":{"start":{"line":225,"column":12},"end":{"line":227,"column":13}},"48":{"start":{"line":226,"column":16},"end":{"line":226,"column":29}},"49":{"start":{"line":229,"column":12},"end":{"line":229,"column":62}},"50":{"start":{"line":239,"column":12},"end":{"line":241,"column":13}},"51":{"start":{"line":240,"column":16},"end":{"line":240,"column":28}},"52":{"start":{"line":244,"column":12},"end":{"line":246,"column":13}},"53":{"start":{"line":245,"column":16},"end":{"line":245,"column":51}},"54":{"start":{"line":247,"column":12},"end":{"line":249,"column":13}},"55":{"start":{"line":248,"column":16},"end":{"line":248,"column":51}},"56":{"start":{"line":250,"column":12},"end":{"line":252,"column":13}},"57":{"start":{"line":251,"column":16},"end":{"line":251,"column":55}},"58":{"start":{"line":255,"column":12},"end":{"line":255,"column":24}},"59":{"start":{"line":259,"column":8},"end":{"line":269,"column":10}},"60":{"start":{"line":261,"column":28},"end":{"line":264,"column":45}},"61":{"start":{"line":265,"column":16},"end":{"line":267,"column":17}},"62":{"start":{"line":266,"column":20},"end":{"line":266,"column":74}}},"fnMap":{"0":{"name":"alwaysTrue","decl":{"start":{"line":15,"column":9},"end":{"line":15,"column":19}},"loc":{"start":{"line":15,"column":22},"end":{"line":17,"column":1}},"line":15},"1":{"name":"alwaysFalse","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":20}},"loc":{"start":{"line":23,"column":23},"end":{"line":25,"column":1}},"line":23},"2":{"name":"(anonymous_2)","decl":{"start":{"line":64,"column":12},"end":{"line":64,"column":13}},"loc":{"start":{"line":64,"column":31},"end":{"line":270,"column":5}},"line":64},"3":{"name":"looksLikeDirective","decl":{"start":{"line":75,"column":17},"end":{"line":75,"column":35}},"loc":{"start":{"line":75,"column":42},"end":{"line":78,"column":9}},"line":75},"4":{"name":"takeWhile","decl":{"start":{"line":85,"column":17},"end":{"line":85,"column":26}},"loc":{"start":{"line":85,"column":44},"end":{"line":92,"column":9}},"line":85},"5":{"name":"directives","decl":{"start":{"line":98,"column":17},"end":{"line":98,"column":27}},"loc":{"start":{"line":98,"column":34},"end":{"line":100,"column":9}},"line":98},"6":{"name":"isDirective","decl":{"start":{"line":107,"column":17},"end":{"line":107,"column":28}},"loc":{"start":{"line":107,"column":46},"end":{"line":120,"column":9}},"line":107},"7":{"name":"(anonymous_7)","decl":{"start":{"line":127,"column":12},"end":{"line":127,"column":13}},"loc":{"start":{"line":127,"column":31},"end":{"line":129,"column":13}},"line":127},"8":{"name":"(anonymous_8)","decl":{"start":{"line":134,"column":12},"end":{"line":134,"column":13}},"loc":{"start":{"line":134,"column":34},"end":{"line":136,"column":13}},"line":134},"9":{"name":"(anonymous_9)","decl":{"start":{"line":138,"column":12},"end":{"line":138,"column":13}},"loc":{"start":{"line":138,"column":40},"end":{"line":143,"column":13}},"line":138},"10":{"name":"(anonymous_10)","decl":{"start":{"line":147,"column":12},"end":{"line":147,"column":13}},"loc":{"start":{"line":147,"column":25},"end":{"line":149,"column":13}},"line":147},"11":{"name":"(anonymous_11)","decl":{"start":{"line":150,"column":12},"end":{"line":150,"column":13}},"loc":{"start":{"line":150,"column":26},"end":{"line":152,"column":13}},"line":150},"12":{"name":"(anonymous_12)","decl":{"start":{"line":153,"column":12},"end":{"line":153,"column":13}},"loc":{"start":{"line":153,"column":36},"end":{"line":158,"column":13}},"line":153},"13":{"name":"(anonymous_13)","decl":{"start":{"line":163,"column":12},"end":{"line":163,"column":13}},"loc":{"start":{"line":163,"column":39},"end":{"line":165,"column":13}},"line":163},"14":{"name":"(anonymous_14)","decl":{"start":{"line":168,"column":12},"end":{"line":168,"column":13}},"loc":{"start":{"line":168,"column":34},"end":{"line":170,"column":13}},"line":168},"15":{"name":"isChaiExpectCall","decl":{"start":{"line":179,"column":17},"end":{"line":179,"column":33}},"loc":{"start":{"line":179,"column":40},"end":{"line":186,"column":9}},"line":179},"16":{"name":"findExpectCall","decl":{"start":{"line":193,"column":17},"end":{"line":193,"column":31}},"loc":{"start":{"line":193,"column":38},"end":{"line":212,"column":9}},"line":193},"17":{"name":"isChaiShouldCall","decl":{"start":{"line":220,"column":17},"end":{"line":220,"column":33}},"loc":{"start":{"line":220,"column":40},"end":{"line":230,"column":9}},"line":220},"18":{"name":"findShouldCall","decl":{"start":{"line":237,"column":17},"end":{"line":237,"column":31}},"loc":{"start":{"line":237,"column":38},"end":{"line":256,"column":9}},"line":237},"19":{"name":"(anonymous_19)","decl":{"start":{"line":260,"column":33},"end":{"line":260,"column":34}},"loc":{"start":{"line":260,"column":48},"end":{"line":268,"column":13}},"line":260}},"branchMap":{"0":{"loc":{"start":{"line":65,"column":21},"end":{"line":65,"column":45}},"type":"binary-expr","locations":[{"start":{"line":65,"column":21},"end":{"line":65,"column":39}},{"start":{"line":65,"column":43},"end":{"line":65,"column":45}}],"line":65},"1":{"loc":{"start":{"line":66,"column":32},"end":{"line":66,"column":65}},"type":"binary-expr","locations":[{"start":{"line":66,"column":32},"end":{"line":66,"column":56}},{"start":{"line":66,"column":60},"end":{"line":66,"column":65}}],"line":66},"2":{"loc":{"start":{"line":67,"column":27},"end":{"line":67,"column":55}},"type":"binary-expr","locations":[{"start":{"line":67,"column":27},"end":{"line":67,"column":46}},{"start":{"line":67,"column":50},"end":{"line":67,"column":55}}],"line":67},"3":{"loc":{"start":{"line":68,"column":35},"end":{"line":68,"column":71}},"type":"binary-expr","locations":[{"start":{"line":68,"column":35},"end":{"line":68,"column":62}},{"start":{"line":68,"column":66},"end":{"line":68,"column":71}}],"line":68},"4":{"loc":{"start":{"line":69,"column":28},"end":{"line":69,"column":57}},"type":"binary-expr","locations":[{"start":{"line":69,"column":28},"end":{"line":69,"column":48}},{"start":{"line":69,"column":52},"end":{"line":69,"column":57}}],"line":69},"5":{"loc":{"start":{"line":76,"column":19},"end":{"line":77,"column":95}},"type":"binary-expr","locations":[{"start":{"line":76,"column":19},"end":{"line":76,"column":54}},{"start":{"line":77,"column":16},"end":{"line":77,"column":50}},{"start":{"line":77,"column":54},"end":{"line":77,"column":95}}],"line":76},"6":{"loc":{"start":{"line":87,"column":16},"end":{"line":89,"column":17}},"type":"if","locations":[{"start":{"line":87,"column":16},"end":{"line":89,"column":17}},{"start":{"line":87,"column":16},"end":{"line":89,"column":17}}],"line":87},"7":{"loc":{"start":{"line":117,"column":19},"end":{"line":119,"column":57}},"type":"binary-expr","locations":[{"start":{"line":117,"column":20},"end":{"line":117,"column":45}},{"start":{"line":117,"column":49},"end":{"line":117,"column":81}},{"start":{"line":118,"column":21},"end":{"line":118,"column":54}},{"start":{"line":119,"column":20},"end":{"line":119,"column":57}}],"line":117},"8":{"loc":{"start":{"line":128,"column":24},"end":{"line":128,"column":57}},"type":"binary-expr","locations":[{"start":{"line":128,"column":24},"end":{"line":128,"column":42}},{"start":{"line":128,"column":46},"end":{"line":128,"column":57}}],"line":128},"9":{"loc":{"start":{"line":139,"column":16},"end":{"line":141,"column":17}},"type":"if","locations":[{"start":{"line":139,"column":16},"end":{"line":141,"column":17}},{"start":{"line":139,"column":16},"end":{"line":141,"column":17}}],"line":139},"10":{"loc":{"start":{"line":140,"column":27},"end":{"line":140,"column":104}},"type":"binary-expr","locations":[{"start":{"line":140,"column":27},"end":{"line":140,"column":64}},{"start":{"line":140,"column":68},"end":{"line":140,"column":104}}],"line":140},"11":{"loc":{"start":{"line":154,"column":16},"end":{"line":156,"column":17}},"type":"if","locations":[{"start":{"line":154,"column":16},"end":{"line":156,"column":17}},{"start":{"line":154,"column":16},"end":{"line":156,"column":17}}],"line":154},"12":{"loc":{"start":{"line":169,"column":23},"end":{"line":169,"column":77}},"type":"binary-expr","locations":[{"start":{"line":169,"column":23},"end":{"line":169,"column":47}},{"start":{"line":169,"column":51},"end":{"line":169,"column":77}}],"line":169},"13":{"loc":{"start":{"line":181,"column":12},"end":{"line":183,"column":13}},"type":"if","locations":[{"start":{"line":181,"column":12},"end":{"line":183,"column":13}},{"start":{"line":181,"column":12},"end":{"line":183,"column":13}}],"line":181},"14":{"loc":{"start":{"line":195,"column":12},"end":{"line":197,"column":13}},"type":"if","locations":[{"start":{"line":195,"column":12},"end":{"line":197,"column":13}},{"start":{"line":195,"column":12},"end":{"line":197,"column":13}}],"line":195},"15":{"loc":{"start":{"line":195,"column":16},"end":{"line":195,"column":116}},"type":"binary-expr","locations":[{"start":{"line":195,"column":16},"end":{"line":195,"column":46}},{"start":{"line":195,"column":50},"end":{"line":195,"column":83}},{"start":{"line":195,"column":87},"end":{"line":195,"column":116}}],"line":195},"16":{"loc":{"start":{"line":200,"column":12},"end":{"line":202,"column":13}},"type":"if","locations":[{"start":{"line":200,"column":12},"end":{"line":202,"column":13}},{"start":{"line":200,"column":12},"end":{"line":202,"column":13}}],"line":200},"17":{"loc":{"start":{"line":203,"column":12},"end":{"line":205,"column":13}},"type":"if","locations":[{"start":{"line":203,"column":12},"end":{"line":205,"column":13}},{"start":{"line":203,"column":12},"end":{"line":205,"column":13}}],"line":203},"18":{"loc":{"start":{"line":206,"column":12},"end":{"line":208,"column":13}},"type":"if","locations":[{"start":{"line":206,"column":12},"end":{"line":208,"column":13}},{"start":{"line":206,"column":12},"end":{"line":208,"column":13}}],"line":206},"19":{"loc":{"start":{"line":222,"column":12},"end":{"line":224,"column":13}},"type":"if","locations":[{"start":{"line":222,"column":12},"end":{"line":224,"column":13}},{"start":{"line":222,"column":12},"end":{"line":224,"column":13}}],"line":222},"20":{"loc":{"start":{"line":225,"column":12},"end":{"line":227,"column":13}},"type":"if","locations":[{"start":{"line":225,"column":12},"end":{"line":227,"column":13}},{"start":{"line":225,"column":12},"end":{"line":227,"column":13}}],"line":225},"21":{"loc":{"start":{"line":239,"column":12},"end":{"line":241,"column":13}},"type":"if","locations":[{"start":{"line":239,"column":12},"end":{"line":241,"column":13}},{"start":{"line":239,"column":12},"end":{"line":241,"column":13}}],"line":239},"22":{"loc":{"start":{"line":239,"column":16},"end":{"line":239,"column":100}},"type":"binary-expr","locations":[{"start":{"line":239,"column":16},"end":{"line":239,"column":48}},{"start":{"line":239,"column":52},"end":{"line":239,"column":65}},{"start":{"line":239,"column":69},"end":{"line":239,"column":100}}],"line":239},"23":{"loc":{"start":{"line":244,"column":12},"end":{"line":246,"column":13}},"type":"if","locations":[{"start":{"line":244,"column":12},"end":{"line":246,"column":13}},{"start":{"line":244,"column":12},"end":{"line":246,"column":13}}],"line":244},"24":{"loc":{"start":{"line":247,"column":12},"end":{"line":249,"column":13}},"type":"if","locations":[{"start":{"line":247,"column":12},"end":{"line":249,"column":13}},{"start":{"line":247,"column":12},"end":{"line":249,"column":13}}],"line":247},"25":{"loc":{"start":{"line":250,"column":12},"end":{"line":252,"column":13}},"type":"if","locations":[{"start":{"line":250,"column":12},"end":{"line":252,"column":13}},{"start":{"line":250,"column":12},"end":{"line":252,"column":13}}],"line":250},"26":{"loc":{"start":{"line":261,"column":28},"end":{"line":264,"column":45}},"type":"binary-expr","locations":[{"start":{"line":261,"column":28},"end":{"line":261,"column":66}},{"start":{"line":262,"column":23},"end":{"line":262,"column":64}},{"start":{"line":263,"column":23},"end":{"line":263,"column":45}},{"start":{"line":264,"column":23},"end":{"line":264,"column":45}}],"line":261},"27":{"loc":{"start":{"line":265,"column":16},"end":{"line":267,"column":17}},"type":"if","locations":[{"start":{"line":265,"column":16},"end":{"line":267,"column":17}},{"start":{"line":265,"column":16},"end":{"line":267,"column":17}}],"line":265}},"s":{"0":45,"1":27,"2":1,"3":81,"4":81,"5":81,"6":81,"7":81,"8":66,"9":52,"10":52,"11":66,"12":51,"13":1,"14":52,"15":57,"16":57,"17":57,"18":81,"19":109,"20":9,"21":7,"22":5,"23":2,"24":2,"25":2,"26":10,"27":6,"28":4,"29":3,"30":4,"31":48,"32":48,"33":39,"34":9,"35":38,"36":3,"37":35,"38":26,"39":9,"40":3,"41":6,"42":0,"43":6,"44":45,"45":45,"46":7,"47":45,"48":32,"49":13,"50":38,"51":5,"52":33,"53":22,"54":11,"55":3,"56":8,"57":0,"58":8,"59":81,"60":86,"61":86,"62":40},"f":{"0":45,"1":27,"2":81,"3":66,"4":52,"5":52,"6":57,"7":109,"8":9,"9":7,"10":2,"11":2,"12":10,"13":3,"14":4,"15":48,"16":38,"17":45,"18":38,"19":86},"b":{"0":[81,60],"1":[81,74],"2":[81,75],"3":[81,78],"4":[81,77],"5":[66,62,16],"6":[51,15],"7":[57,13,10,52],"8":[109,27],"9":[5,2],"10":[5,3],"11":[6,4],"12":[4,3],"13":[39,9],"14":[3,35],"15":[38,6,3],"16":[26,9],"17":[3,6],"18":[0,6],"19":[7,38],"20":[32,13],"21":[5,33],"22":[38,27,27],"23":[22,11],"24":[3,8],"25":[0,8],"26":[86,57,48,45],"27":[40,46]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"668d4d410897bcaf3f08579a2c33109613daba5c","contentHash":"edc38d3419bbdf0ba857c59c0024ca79a32b69ef8f8f6ab96257931ec2cbfacd"}}
@@ -1 +0,0 @@
1
- {"parent":null,"pid":4979,"argv":["/usr/local/bin/node","/Users/user/repos/eslint-plugin-chai-friendly/node_modules/.bin/mocha","tests","--recursive"],"execArgv":[],"cwd":"/Users/user/repos/eslint-plugin-chai-friendly","time":1704676611646,"ppid":4978,"coverageFilename":"/Users/user/repos/eslint-plugin-chai-friendly/.nyc_output/676c2c95-b21a-4c9b-8561-ccdf602fa0c1.json","externalId":"","uuid":"676c2c95-b21a-4c9b-8561-ccdf602fa0c1","files":["/Users/user/repos/eslint-plugin-chai-friendly/lib/rules/no-unused-expressions.js"]}
@@ -1 +0,0 @@
1
- {"processes":{"676c2c95-b21a-4c9b-8561-ccdf602fa0c1":{"parent":null,"children":[]}},"files":{"/Users/user/repos/eslint-plugin-chai-friendly/lib/rules/no-unused-expressions.js":["676c2c95-b21a-4c9b-8561-ccdf602fa0c1"]},"externalIds":{}}
@@ -1,247 +0,0 @@
1
- /**
2
- * @fileoverview Tests for no-unused-expressions rule.
3
- * @author Michael Ficarra
4
- */
5
-
6
-
7
- //------------------------------------------------------------------------------
8
- // Requirements
9
- //------------------------------------------------------------------------------
10
-
11
- var rule = require("../../../lib/rules/no-unused-expressions.js")
12
- var RuleTester = require('eslint').RuleTester;
13
-
14
- //------------------------------------------------------------------------------
15
- // Tests
16
- //------------------------------------------------------------------------------
17
-
18
- var ruleTester = new RuleTester();
19
-
20
- ruleTester.run("no-unused-expressions", rule, {
21
- valid: [
22
- "function f(){}",
23
- "a = b",
24
- "new a",
25
- "{}",
26
- "f(); g()",
27
- "i++",
28
- "a()",
29
- { code: "a && a()", options: [{ allowShortCircuit: true }]},
30
- { code: "a() || (b = c)", options: [{ allowShortCircuit: true }]},
31
- { code: "a ? b() : c()", options: [{ allowTernary: true }]},
32
- { code: "a ? b() || (c = d) : e()", options: [{ allowShortCircuit: true, allowTernary: true }]},
33
- "delete foo.bar",
34
- "void new C",
35
- "\"use strict\";",
36
- "\"directive one\"; \"directive two\"; f();",
37
- "function foo() {\"use strict\"; return true; }",
38
- { code: "var foo = () => {\"use strict\"; return true; }", parserOptions: { ecmaVersion: 6 }},
39
- "function foo() {\"directive one\"; \"directive two\"; f(); }",
40
- "function foo() { var foo = \"use strict\"; return true; }",
41
- {
42
- code: "function* foo(){ yield 0; }",
43
- parserOptions: { ecmaVersion: 6 }
44
- },
45
- {
46
- code: "async function foo() { await 5; }",
47
- parserOptions: { ecmaVersion: 8 }
48
- },
49
- {
50
- code: "async function foo() { await foo.bar; }",
51
- parserOptions: { ecmaVersion: 8 }
52
- },
53
- {
54
- code: "async function foo() { bar && await baz; }",
55
- options: [{ allowShortCircuit: true }],
56
- parserOptions: { ecmaVersion: 8 }
57
- },
58
- {
59
- code: "async function foo() { foo ? await bar : await baz; }",
60
- options: [{ allowTernary: true }],
61
- parserOptions: { ecmaVersion: 8 }
62
- },
63
- {
64
- code: "tag`tagged template literal`",
65
- options: [{ allowTaggedTemplates: true }],
66
- parserOptions: { ecmaVersion: 6 }
67
- },
68
- {
69
- code: "shouldNotBeAffectedByAllowTemplateTagsOption()",
70
- options: [{ allowTaggedTemplates: true }],
71
- parserOptions: { ecmaVersion: 6 }
72
- },
73
- {
74
- code: "import(\"foo\")",
75
- parserOptions: { ecmaVersion: 11 }
76
- },
77
- {
78
- code: "func?.(\"foo\")",
79
- parserOptions: { ecmaVersion: 11 }
80
- },
81
- {
82
- code: "obj?.foo(\"bar\")",
83
- parserOptions: { ecmaVersion: 11 }
84
- },
85
- // JSX
86
- {
87
- code: "<div />",
88
- parserOptions: { ecmaFeatures: { jsx: true } }
89
- },
90
- {
91
- code: "<></>",
92
- parserOptions: { ecmaFeatures: { jsx: true } }
93
- },
94
- {
95
- code: "var partial = <div />",
96
- parserOptions: { ecmaFeatures: { jsx: true } }
97
- },
98
- {
99
- code: "var partial = <div />",
100
- options: [{ enforceForJSX: true }],
101
- parserOptions: { ecmaFeatures: { jsx: true } }
102
- },
103
- {
104
- code: "var partial = <></>",
105
- options: [{ enforceForJSX: true }],
106
- parserOptions: { ecmaFeatures: { jsx: true } }
107
- },
108
-
109
- // Chai statements
110
- "expect(foo).to.be.true;",
111
- "expect(foo).to.have.a.property('bar').which.is.true",
112
- "foo.should.be.true;",
113
- "foo.inner.nested.should.be.true",
114
- "foo.should.have.a.property('bar').which.is.true;",
115
- {
116
- code: "foo?.should.be.true;",
117
- parserOptions: { ecmaVersion: 11 }
118
- },
119
- {
120
- code: "foo?.bar?.should.be.true;",
121
- parserOptions: { ecmaVersion: 11 }
122
- },
123
- {
124
- code: "expect(foo?.bar).should.be.true;",
125
- parserOptions: { ecmaVersion: 11 }
126
- }
127
- ],
128
- invalid: [
129
- { code: "0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
130
- { code: "a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
131
- { code: "f(), 0", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
132
- { code: "{0}", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
133
- { code: "[]", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
134
- { code: "a && b();", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
135
- { code: "a() || false", errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]},
136
- { code: "a || (b = c)", errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]},
137
- { code: "a ? b() || (c = d) : e", errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]},
138
- { code: "a && b()", options: [{ allowTernary: true }], errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]},
139
- { code: "a ? b() : c()", options: [{ allowShortCircuit: true }], errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]},
140
- { code: "a || b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
141
- { code: "a() && b", options: [{ allowShortCircuit: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
142
- { code: "a ? b : 0", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
143
- { code: "a ? b : c()", options: [{ allowTernary: true }], errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
144
- { code: "foo.bar;", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
145
- { code: "!a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
146
- { code: "+a", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
147
- { code: "\"directive one\"; f(); \"directive two\";", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
148
- { code: "function foo() {\"directive one\"; f(); \"directive two\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
149
- { code: "if (0) { \"not a directive\"; f(); }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
150
- { code: "function foo() { var foo = true; \"use strict\"; }", errors: [{ message: "Expected an assignment or function call and instead saw an expression.", type: "ExpressionStatement"}]},
151
- { 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"}]},
152
- {
153
- code: "`untagged template literal`",
154
- options: [{ allowTaggedTemplates: true }],
155
- parserOptions: { ecmaVersion: 6},
156
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
157
- },
158
- {
159
- code: "`untagged template literal`",
160
- options: [{ allowTaggedTemplates: false }],
161
- parserOptions: { ecmaVersion: 6},
162
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
163
- },
164
- {
165
- code: "tag`tagged template literal`",
166
- options: [{ allowTaggedTemplates: false }],
167
- parserOptions: { ecmaVersion: 6},
168
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
169
- },
170
- {
171
- code: "`untagged template literal`",
172
- parserOptions: { ecmaVersion: 6 },
173
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
174
- },
175
- {
176
- code: "tag`tagged template literal`",
177
- parserOptions: { ecmaVersion: 6 },
178
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
179
- },
180
-
181
- // Optional chaining
182
- {
183
- code: "obj?.foo",
184
- parserOptions: { ecmaVersion: 2020 },
185
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
186
- },
187
- {
188
- code: "obj?.foo.bar",
189
- parserOptions: { ecmaVersion: 2020 },
190
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
191
- },
192
- {
193
- code: "obj?.foo().bar",
194
- parserOptions: { ecmaVersion: 2020 },
195
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
196
- },
197
- // JSX
198
- {
199
- code: "<div />",
200
- options: [{ enforceForJSX: true }],
201
- parserOptions: { ecmaFeatures: { jsx: true } },
202
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
203
- },
204
- {
205
- code: "<></>",
206
- options: [{ enforceForJSX: true }],
207
- parserOptions: { ecmaFeatures: { jsx: true } },
208
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
209
- },
210
- // class static blocks do not have directive prologues
211
- {
212
- code: "class C { static { 'use strict'; } }",
213
- parserOptions: { ecmaVersion: 2022 },
214
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
215
- },
216
- {
217
- code: "class C { static { \n'foo'\n'bar'\n } }",
218
- parserOptions: { ecmaVersion: 2022 },
219
- errors: [
220
- {
221
- messageId: "unusedExpression",
222
- type: "ExpressionStatement",
223
- line: 2
224
- },
225
- {
226
- messageId: "unusedExpression",
227
- type: "ExpressionStatement",
228
- line: 3
229
- }
230
- ]
231
- },
232
-
233
- // Chai statements
234
- { code: "foo.expect('bar').not.to.pass;", errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]},
235
- { code: "should.not.pass;", errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }] },
236
- {
237
- code: "foo?.expect.to.be.true;",
238
- parserOptions: { ecmaVersion: 11 },
239
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
240
- },
241
- {
242
- code: "foo?.bar?.expect.to.be.true;",
243
- parserOptions: { ecmaVersion: 11 },
244
- errors: [{ messageId: "unusedExpression", type: "ExpressionStatement" }]
245
- }
246
- ]
247
- });