eslint-plugin-new-with-error 2.0.0 → 3.0.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/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ # [3.0.0](https://github.com/Trott/eslint-plugin-new-with-error/compare/v2.0.0...v3.0.0) (2021-11-18)
2
+
3
+
4
+ ### chore
5
+
6
+ * test all versions of ESLint that we support ([#24](https://github.com/Trott/eslint-plugin-new-with-error/issues/24)) ([221a5fc](https://github.com/Trott/eslint-plugin-new-with-error/commit/221a5fc3ff799b54c7fb5ff3c6d87856e190605d))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * drop support for Node.js < 12.x.
12
+
1
13
  # Changelog
2
14
 
3
15
  ## 2.0.0
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
3
  module.exports = {
4
4
  rules: {
@@ -7,4 +7,4 @@ module.exports = {
7
7
  rulesConfig: {
8
8
  'new-with-error': 1
9
9
  }
10
- };
10
+ }
@@ -4,29 +4,27 @@
4
4
  * @copyright Rich Trott. All rights reserved.
5
5
  * See LICENSE file in root directory for full license.
6
6
  */
7
- "use strict";
7
+ 'use strict'
8
8
 
9
- //------------------------------------------------------------------------------
9
+ // ------------------------------------------------------------------------------
10
10
  // Rule Definition
11
- //------------------------------------------------------------------------------
11
+ // ------------------------------------------------------------------------------
12
12
 
13
- module.exports = function(context) {
13
+ module.exports = function (context) {
14
+ const defaultErrorsList = ['Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError']
14
15
 
15
- var defaultErrorsList = ['Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError'];
16
+ const errorList = context.options.length !== 0 ? context.options : defaultErrorsList
16
17
 
17
- var errorList = context.options.length !== 0 ? context.options : defaultErrorsList;
18
+ // --------------------------------------------------------------------------
19
+ // Public
20
+ // --------------------------------------------------------------------------
18
21
 
19
- //--------------------------------------------------------------------------
20
- // Public
21
- //--------------------------------------------------------------------------
22
+ return {
22
23
 
23
- return {
24
-
25
- 'ThrowStatement': function(node) {
26
- if (node.argument.type === 'CallExpression' && errorList.indexOf(node.argument.callee.name) !== -1) {
27
- context.report(node, 'Use new keyword when throwing.');
28
- }
29
- }
30
- };
31
-
32
- };
24
+ ThrowStatement: function (node) {
25
+ if (node.argument.type === 'CallExpression' && errorList.indexOf(node.argument.callee.name) !== -1) {
26
+ context.report(node, 'Use new keyword when throwing.')
27
+ }
28
+ }
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-new-with-error",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "Require `throw new Error()` and not `throw Error()`",
5
5
  "repository": "https://github.com/Trott/eslint-plugin-new-with-error",
6
6
  "directories": {
@@ -8,7 +8,9 @@
8
8
  "test": "tests"
9
9
  },
10
10
  "scripts": {
11
- "test": "node tests/lib/rules/new-with-error.js"
11
+ "pretest": "standard",
12
+ "test": "for eslintVersion in 2.13.1 3 4 5 6 7 8; do npm install --no-save eslint@${eslintVersion} && c8 --check-coverage --branches 100 --functions 100 --lines 100 node tests/lib/rules/new-with-error.js || exit 1; done",
13
+ "posttest": "npm ci"
12
14
  },
13
15
  "keywords": [
14
16
  "eslint",
@@ -20,7 +22,37 @@
20
22
  "eslint": ">=2.13.1"
21
23
  },
22
24
  "devDependencies": {
23
- "eslint": "^5.0.1"
25
+ "@semantic-release/changelog": "^6.0.1",
26
+ "@semantic-release/git": "^10.0.1",
27
+ "c8": "^7.10.0",
28
+ "eslint": "^8.2.0",
29
+ "semantic-release": "^18.0.0",
30
+ "standard": "^16.0.4"
24
31
  },
25
- "dependencies": {}
32
+ "release": {
33
+ "branches": [
34
+ "main"
35
+ ],
36
+ "plugins": [
37
+ "@semantic-release/commit-analyzer",
38
+ "@semantic-release/release-notes-generator",
39
+ [
40
+ "@semantic-release/changelog",
41
+ {
42
+ "changelogFile": "CHANGELOG"
43
+ }
44
+ ],
45
+ "@semantic-release/npm",
46
+ [
47
+ "@semantic-release/git",
48
+ {
49
+ "assets": [
50
+ "CHANGELOG",
51
+ "package.json"
52
+ ],
53
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
54
+ }
55
+ ]
56
+ ]
57
+ }
26
58
  }
@@ -1,36 +0,0 @@
1
- # Require `throw new Error()` rather than `throw Error()` (new-with-error)
2
-
3
- This is a style requirement of Node.js core code. Perhaps you will find it useful too.
4
-
5
-
6
- ## Rule Details
7
-
8
- This rule aims to make sure that there is consistency with how Errors are thrown.
9
-
10
- The following patterns are considered warnings:
11
-
12
- ```js
13
-
14
- throw Error('foo');
15
-
16
- ```
17
-
18
- The following patterns are not warnings:
19
-
20
- ```js
21
-
22
- throw new Error('foo');
23
-
24
- ```
25
-
26
- ### Options
27
-
28
- You can include an array of Error types you want checked (SyntaxError, ReferenceError, etc.). Or don't provide it and you'll get checks on Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, and URIError.
29
-
30
- ## When Not To Use It
31
-
32
- If you don't care if there's a mix of `throw Error()` and `throw new Error()` in your code, then this is not the rule for you.
33
-
34
- ## Further Reading
35
-
36
- * https://github.com/nodejs/node/pull/3714
@@ -1,51 +0,0 @@
1
- /**
2
- * @fileoverview Require `throw new Error()` rather than `throw Error()`
3
- * @author Rich Trott
4
- * @copyright 2015 Rich Trott. All rights reserved.
5
- * See LICENSE file in root directory for full license.
6
- */
7
- "use strict";
8
-
9
- //------------------------------------------------------------------------------
10
- // Requirements
11
- //------------------------------------------------------------------------------
12
-
13
- var rule = require("../../../lib/rules/new-with-error"),
14
-
15
- RuleTester = require("eslint").RuleTester;
16
-
17
-
18
- //------------------------------------------------------------------------------
19
- // Tests
20
- //------------------------------------------------------------------------------
21
-
22
- var ruleTester = new RuleTester();
23
- ruleTester.run("new-with-error", rule, {
24
-
25
- valid: [
26
- {
27
- code: "throw new Error();"
28
- },
29
- {
30
- code: "throw SyntaxError();",
31
- options: ['Error']
32
- }
33
- ],
34
-
35
- invalid: [
36
- {
37
- code: "throw Error();",
38
- errors: [{
39
- message: "Use new keyword when throwing.",
40
- type: "ThrowStatement"
41
- }]
42
- },
43
- {
44
- code: "throw SyntaxError();",
45
- errors: [{
46
- message: "Use new keyword when throwing.",
47
- type: "ThrowStatement"
48
- }]
49
- }
50
- ]
51
- });