-
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.
Add rules for no-context/selector-prop and include in deprecated-1.10…
- Loading branch information
1 parent
87c753c
commit 66263ad
Showing
6 changed files
with
153 additions
and
3 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
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,26 @@ | ||
'use strict' | ||
|
||
const utils = require('./utils.js') | ||
|
||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
schema: [] | ||
}, | ||
|
||
create: function(context) { | ||
return { | ||
MemberExpression: function(node) { | ||
if (node.property.name !== 'context') return | ||
if (node.parent.callee === node) return | ||
|
||
if (utils.isjQuery(node)) { | ||
context.report({ | ||
node: node, | ||
message: '$.context 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,26 @@ | ||
'use strict' | ||
|
||
const utils = require('./utils.js') | ||
|
||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
schema: [] | ||
}, | ||
|
||
create: function(context) { | ||
return { | ||
MemberExpression: function(node) { | ||
if (node.property.name !== 'selector') return | ||
if (node.parent.callee === node) return | ||
|
||
if (utils.isjQuery(node)) { | ||
context.report({ | ||
node: node, | ||
message: '$.selector 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,47 @@ | ||
'use strict' | ||
|
||
const rule = require('../rules/no-context-prop') | ||
const RuleTester = require('eslint').RuleTester | ||
|
||
const error = '$.context is not allowed' | ||
|
||
const ruleTester = new RuleTester() | ||
ruleTester.run('no-context-prop', rule, { | ||
valid: [ | ||
'context', | ||
'div.context', | ||
'$div.prop.context', | ||
'$div.context()', | ||
'$div.context(arg)' | ||
], | ||
invalid: [ | ||
{ | ||
code: '$("div").context', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$div.context', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$div.context.prop', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$div.context.method()', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$("div").first().context', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: 'f($div.context)', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$("div").append($("input").context)', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
} | ||
] | ||
}) |
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,47 @@ | ||
'use strict' | ||
|
||
const rule = require('../rules/no-selector-prop') | ||
const RuleTester = require('eslint').RuleTester | ||
|
||
const error = '$.selector is not allowed' | ||
|
||
const ruleTester = new RuleTester() | ||
ruleTester.run('no-selector-prop', rule, { | ||
valid: [ | ||
'selector', | ||
'div.selector', | ||
'$div.prop.selector', | ||
'$div.selector()', | ||
'$div.selector(arg)' | ||
], | ||
invalid: [ | ||
{ | ||
code: '$("div").selector', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$div.selector', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$div.selector.prop', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$div.selector.method()', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$("div").first().selector', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: 'f($div.selector)', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
}, | ||
{ | ||
code: '$("div").append($("input").selector)', | ||
errors: [{message: error, type: 'MemberExpression'}] | ||
} | ||
] | ||
}) |