-
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.
In slim mode, $.fx is completely missing, so create a rule for this (more generic that no-fx-interval, which exists as that property is deprecated).
- Loading branch information
1 parent
4039675
commit 238c2ea
Showing
5 changed files
with
95 additions
and
0 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,30 @@ | ||
[//]: # (This file is generated by eslint-docgen. Do not edit it directly.) | ||
|
||
# no-fx | ||
|
||
Disallows `$.fx`. | ||
|
||
📋 This rule is enabled in `plugin:no-jquery/slim`. | ||
|
||
## Rule details | ||
|
||
❌ Examples of **incorrect** code: | ||
```js | ||
$.fx; | ||
$.fx.interval; | ||
$.fx.off; | ||
$.fx.speeds.slow; | ||
$.fx.start(); | ||
``` | ||
|
||
✔️ Examples of **correct** code: | ||
```js | ||
fx; | ||
fx.interval; | ||
a.fx; | ||
``` | ||
|
||
## Resources | ||
|
||
* [Rule source](/src/rules/no-fx.js) | ||
* [Test source](/tests/rules/no-fx.js) |
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,29 @@ | ||
'use strict'; | ||
|
||
const utils = require( '../utils.js' ); | ||
|
||
module.exports = { | ||
meta: { | ||
type: 'suggestion', | ||
docs: { | ||
description: 'Disallows `$.fx`.' | ||
}, | ||
schema: [] | ||
}, | ||
|
||
create: ( context ) => ( { | ||
MemberExpression: ( node ) => { | ||
if ( | ||
!utils.isjQueryConstructor( context, node.object.name ) || | ||
node.property.name !== 'fx' | ||
) { | ||
return; | ||
} | ||
|
||
context.report( { | ||
node, | ||
message: '$.fx is not allowed' | ||
} ); | ||
} | ||
} ) | ||
}; |
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,33 @@ | ||
'use strict'; | ||
|
||
const rule = require( '../../src/rules/no-fx' ); | ||
const RuleTester = require( '../../tools/rule-tester' ); | ||
|
||
const error = '$.fx is not allowed'; | ||
|
||
const ruleTester = new RuleTester(); | ||
ruleTester.run( 'no-fx', rule, { | ||
valid: [ 'fx', 'fx.interval', 'a.fx' ], | ||
invalid: [ | ||
{ | ||
code: '$.fx', | ||
errors: [ error ] | ||
}, | ||
{ | ||
code: '$.fx.interval', | ||
errors: [ error ] | ||
}, | ||
{ | ||
code: '$.fx.off', | ||
errors: [ error ] | ||
}, | ||
{ | ||
code: '$.fx.speeds.slow', | ||
errors: [ error ] | ||
}, | ||
{ | ||
code: '$.fx.start()', | ||
errors: [ error ] | ||
} | ||
] | ||
} ); |