-
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.
De-deduplicate rule generation (#59)
Creates four generators: * createCollectionMethodRule: $(...).method(...) * createCollectionPropertyRule: $(...).property * createUtilMethodRule: $.method(...) * createUtilPropertyRule: $.property Not touched by this change are rules with more complex criteria, and rules where the distinction hasn't been made between util methods and collection methods e.g. $.text() and $(...).text(). Doesn't touch the tests to ensure no functionality is changed. Part of #55
- Loading branch information
1 parent
bd4e0f4
commit c6a2ce2
Showing
64 changed files
with
338 additions
and
1,315 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,8 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
schema: [] | ||
}, | ||
const utils = require('./utils.js') | ||
|
||
create: function(context) { | ||
return { | ||
CallExpression: function(node) { | ||
if (node.callee.type !== 'MemberExpression') return | ||
if (node.callee.object.name !== '$') return | ||
|
||
const name = node.callee.property.name | ||
switch (name) { | ||
case 'ajax': | ||
case 'get': | ||
case 'getJSON': | ||
case 'getScript': | ||
case 'post': | ||
context.report({ | ||
node: node, | ||
message: 'Prefer fetch to $.' + name | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
module.exports = utils.createUtilMethodRule( | ||
['ajax', 'get', 'getJSON', 'getScript', 'post'], | ||
node => `Prefer fetch to $.${node.callee.property.name}` | ||
) |
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
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 |
---|---|---|
@@ -1,22 +1,5 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
schema: [] | ||
}, | ||
const utils = require('./utils.js') | ||
|
||
create: function(context) { | ||
return { | ||
MemberExpression: function(node) { | ||
if (node.object.name !== '$') return | ||
if (node.property.name !== 'boxModel') return | ||
|
||
context.report({ | ||
node: node, | ||
message: '$.boxModel is not allowed' | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
module.exports = utils.createUtilPropertyRule('boxModel') |
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 |
---|---|---|
@@ -1,22 +1,5 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
meta: { | ||
docs: {}, | ||
schema: [] | ||
}, | ||
const utils = require('./utils.js') | ||
|
||
create: function(context) { | ||
return { | ||
MemberExpression: function(node) { | ||
if (node.object.name !== '$') return | ||
if (node.property.name !== 'browser') return | ||
|
||
context.report({ | ||
node: node, | ||
message: '$.browser is not allowed' | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
module.exports = utils.createUtilPropertyRule('browser') |
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
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
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
Oops, something went wrong.