Skip to content

Commit

Permalink
Add rule for no-fx-interval and include in deprecated-3.0
Browse files Browse the repository at this point in the history
Part of #32
  • Loading branch information
edg2s committed Jan 20, 2019
1 parent d86ac30 commit c0b6d02
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Alternatively, you can pick out rules individually:
"jquery/no-fade": 2,
"jquery/no-filter": 2,
"jquery/no-find": 2,
"jquery/no-fx-interval": 2,
"jquery/no-global-eval": 2,
"jquery/no-grep": 2,
"jquery/no-has": 2,
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
'no-fade': require('./rules/no-fade'),
'no-filter': require('./rules/no-filter'),
'no-find': require('./rules/no-find'),
'no-fx-interval': require('./rules/no-fx-interval'),
'no-global-eval': require('./rules/no-global-eval'),
'no-grep': require('./rules/no-grep'),
'no-has': require('./rules/no-has'),
Expand Down Expand Up @@ -91,7 +92,7 @@ module.exports = {
'jquery/no-unbind': 2,
'jquery/no-delegate': 2,
'jquery/no-undelegate': 2,
// FIXME: `$.fx.interval`
'jquery/no-fx-interval': 2,
'jquery/no-parse-json': 2,
'jquery/no-unique': 2
}
Expand Down
24 changes: 24 additions & 0 deletions rules/no-fx-interval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'

module.exports = {
meta: {
docs: {},
schema: []
},

create: function(context) {
return {
MemberExpression: function(node) {
if (node.object.name !== '$') return
if (node.property.name !== 'fx') return
if (!node.parent.property) return
if (node.parent.property.name !== 'interval') return

context.report({
node: node,
message: '$.fx.interval is not allowed'
})
}
}
}
}
17 changes: 17 additions & 0 deletions tests/no-fx-interval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const rule = require('../rules/no-fx-interval')
const RuleTester = require('eslint').RuleTester

const error = '$.fx.interval is not allowed'

const ruleTester = new RuleTester()
ruleTester.run('no-noop', rule, {
valid: ['interval', 'fx.interval', '$.interval', 'a.fx.interval', '$.fx'],
invalid: [
{
code: '$.fx.interval',
errors: [{message: error, type: 'MemberExpression'}]
}
]
})

0 comments on commit c0b6d02

Please sign in to comment.