You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
I would like to have a eslint rule that checks if the modules are exported in consistent way in all modules.
Now you can export functions in one module like this:
// first you declare and implement all the functions
function findById() { ... do something ...}
function findAll() {}
function incrementViews() {}
module.exports = { // and then all the functions are exported at once
findById,
findAll,
incrementViews
}
and in other module, you can export functions directly when declaring them:
// export the function with the implementation in one line
module.exports.findById = function findById() {
... do something ...
}
module.exports.findAll = function findAll() {
... do something ...
}
module.exports.incrementViews = function incrementViews() {
... do something ...
}
I'm not sure if this kind of rule exists in eslint, but I think it would be nice to have it and this rule would be more important than checking if a comment starts with capital letter 😜
The text was updated successfully, but these errors were encountered:
I like the idea. Basically, what you want is a rule which checks for a single assignment to module.exports or a single export statement (with one extra export default statement allowed, since they are mutually exclusive) in modules.
I will look around if this rule is already implemented somewhere and if not, I will try to submit a proposal to ESLint. Thanks for the idea!
I would like to have a eslint rule that checks if the modules are exported in consistent way in all modules.
Now you can export functions in one module like this:
and in other module, you can export functions directly when declaring them:
I'm not sure if this kind of rule exists in eslint, but I think it would be nice to have it and this rule would be more important than checking if a comment starts with capital letter 😜
The text was updated successfully, but these errors were encountered: