-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #112
- Loading branch information
Showing
5 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# no-error | ||
|
||
Disallows the $.error utility. Prefer throw to $.error. | ||
|
||
## Rule details | ||
|
||
✗ The following patterns are considered errors: | ||
```js | ||
$.error(); | ||
``` | ||
|
||
✓ The following patterns are not considered errors: | ||
```js | ||
nodeName(); | ||
myClass.nodeName(); | ||
$div.nodeName(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
const utils = require( './utils.js' ); | ||
|
||
module.exports = utils.createUtilMethodRule( | ||
'error', | ||
'Prefer throw to $.error' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const rule = require( '../rules/no-error' ); | ||
const RuleTesterAndDocs = require( '../rule-tester-and-docs' ); | ||
|
||
const error = 'Prefer throw to $.error'; | ||
|
||
const ruleTester = new RuleTesterAndDocs(); | ||
ruleTester.run( 'no-error', rule, { | ||
valid: [ 'nodeName()', 'myClass.nodeName()', '$div.nodeName()' ], | ||
invalid: [ | ||
{ | ||
code: '$.error()', | ||
errors: [ { message: error, type: 'CallExpression' } ] | ||
} | ||
] | ||
} ); |