-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(eslint): add custom rule to disallow componentOnReady method (#…
- Loading branch information
1 parent
174c3b3
commit 8629dfa
Showing
10 changed files
with
174 additions
and
220 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,5 @@ | ||
module.exports = { | ||
rules: { | ||
'no-component-on-ready-method': require('./no-component-on-ready-method.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
meta: { | ||
messages: { | ||
noComponentOnReadyMethod: 'Using the componentOnReady method is not allowed. Use the componentOnReady helper utility in src/utils/helpers.ts instead.', | ||
}, | ||
}, | ||
create(context) { | ||
return { | ||
CallExpression(node) { | ||
/** | ||
* We only want to exclude usages of componentOnReady(). | ||
* Checking for the existence of the componentOnReady method | ||
* is a way of determining if we are in a lazy loaded build | ||
* or custom elements build, so we want to allow that. | ||
*/ | ||
const callee = node.callee; | ||
if (callee.type === 'MemberExpression' && callee.property.name === 'componentOnReady') { | ||
context.report({ node: node, messageId: 'noComponentOnReadyMethod' }); | ||
} | ||
} | ||
} | ||
} | ||
}; |
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,5 @@ | ||
{ | ||
"name": "eslint-plugin-custom-rules", | ||
"version": "1.0.0", | ||
"main": "index.js" | ||
} |
Oops, something went wrong.