Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove param names fixer #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -80,7 +80,7 @@ or start with the recommended rule set:
| -------------------------------------------------------- | -------------------------------------------------------------------------------- | ----------- | -------- |
| [`catch-or-return`][catch-or-return] | Enforces the use of `catch()` on un-returned promises. | :bangbang: | |
| [`no-return-wrap`][no-return-wrap] | Avoid wrapping values in `Promise.resolve` or `Promise.reject` when not needed. | :bangbang: | |
| [`param-names`][param-names] | Enforce consistent param names and ordering when creating new promises. | :bangbang: | :wrench: |
| [`param-names`][param-names] | Enforce consistent param names and ordering when creating new promises. | :bangbang: | |
| [`always-return`][always-return] | Return inside each `then()` to create readable and reusable Promise chains. | :bangbang: | |
| [`no-native`][no-native] | In an ES5 environment, make sure to create a `Promise` constructor before using. | | |
| [`no-nesting`][no-nesting] | Avoid nested `then()` or `catch()` statements | :warning: | |
Expand Down
12 changes: 4 additions & 8 deletions __tests__/param-names.js
Expand Up @@ -22,23 +22,19 @@ ruleTester.run('param-names', rule, {
invalid: [
{
code: 'new Promise(function(reject, resolve) {})',
errors: [{ message }],
output: 'new Promise(function(resolve, reject) {})'
errors: [{ message }]
},
{
code: 'new Promise(function(resolve, rej) {})',
errors: [{ message }],
output: 'new Promise(function(resolve, reject) {})'
errors: [{ message }]
},
{
code: 'new Promise(yes => {})',
errors: [{ message }],
output: 'new Promise(resolve => {})'
errors: [{ message }]
},
{
code: 'new Promise((yes, no) => {})',
errors: [{ message }],
output: 'new Promise((resolve, reject) => {})'
errors: [{ message }]
}
]
})
8 changes: 1 addition & 7 deletions rules/param-names.js
Expand Up @@ -26,13 +26,7 @@ module.exports = {
context.report({
node,
message:
'Promise constructor parameters must be named resolve, reject',
fix(fixer) {
return [
fixer.replaceText(params[0], 'resolve'),
params[1] && fixer.replaceText(params[1], 'reject')
].filter(Boolean)
}
'Promise constructor parameters must be named resolve, reject'
})
}
}
Expand Down