eslint-plugin-new-with-error 3.0.0 → 4.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,22 @@
1
+ # [4.0.0](https://github.com/Trott/eslint-plugin-new-with-error/compare/v3.1.0...v4.0.0) (2023-03-27)
2
+
3
+
4
+ ### chore
5
+
6
+ * drop support for Node.js 12.x ([#53](https://github.com/Trott/eslint-plugin-new-with-error/issues/53)) ([7660ef6](https://github.com/Trott/eslint-plugin-new-with-error/commit/7660ef6fc6fba0f2d7d0b639e9d2d579ef5626a3))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * Node.js 14.x or newer is now required
12
+
13
+ # [3.1.0](https://github.com/Trott/eslint-plugin-new-with-error/compare/v3.0.0...v3.1.0) (2021-11-19)
14
+
15
+
16
+ ### Features
17
+
18
+ * make rule fixable ([#25](https://github.com/Trott/eslint-plugin-new-with-error/issues/25)) ([72666f4](https://github.com/Trott/eslint-plugin-new-with-error/commit/72666f4822e2df25f685c8039e282d9739dce8d6))
19
+
1
20
  # [3.0.0](https://github.com/Trott/eslint-plugin-new-with-error/compare/v2.0.0...v3.0.0) (2021-11-18)
2
21
 
3
22
 
@@ -10,8 +29,7 @@
10
29
 
11
30
  * drop support for Node.js < 12.x.
12
31
 
13
- # Changelog
14
32
 
15
- ## 2.0.0
33
+ # 2.0.0
16
34
 
17
35
  Now requires ESLint 2 or higher.
@@ -10,20 +10,34 @@
10
10
  // Rule Definition
11
11
  // ------------------------------------------------------------------------------
12
12
 
13
- module.exports = function (context) {
14
- const defaultErrorsList = ['Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError']
13
+ /**
14
+ * @type {import('eslint').Rule.RuleModule}
15
+ */
16
+ module.exports = {
17
+ meta: {
18
+ fixable: 'code'
19
+ },
20
+ create: function (context) {
21
+ const defaultErrorsList = ['Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError']
15
22
 
16
- const errorList = context.options.length !== 0 ? context.options : defaultErrorsList
23
+ const errorList = context.options.length !== 0 ? context.options : defaultErrorsList
17
24
 
18
- // --------------------------------------------------------------------------
19
- // Public
20
- // --------------------------------------------------------------------------
25
+ // --------------------------------------------------------------------------
26
+ // Public
27
+ // --------------------------------------------------------------------------
21
28
 
22
- return {
29
+ return {
23
30
 
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.')
31
+ ThrowStatement: function (node) {
32
+ if (node.argument.type === 'CallExpression' && errorList.indexOf(node.argument.callee.name) !== -1) {
33
+ context.report({
34
+ message: 'Use new keyword when throwing.',
35
+ node: node,
36
+ fix: function (fixer) {
37
+ return fixer.insertTextBefore(node.argument, 'new ')
38
+ }
39
+ })
40
+ }
27
41
  }
28
42
  }
29
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-new-with-error",
3
- "version": "3.0.0",
3
+ "version": "4.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": {
@@ -24,10 +24,10 @@
24
24
  "devDependencies": {
25
25
  "@semantic-release/changelog": "^6.0.1",
26
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"
27
+ "c8": "^7.11.3",
28
+ "eslint": "^8.15.0",
29
+ "semantic-release": "^20.1.0",
30
+ "standard": "^17.0.0"
31
31
  },
32
32
  "release": {
33
33
  "branches": [