-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Force promise arguments name #282
Comments
what about those who use |
I don't know, I would prefer forcing everyone to use the same, but another approach could be to not allow I think that the best approach is to try the stricter and see how many of the packages we break. The infrastructure for this is already in place and is easy enough to use. |
I'm all for the idea, but I see people do something like this with nested promises: return new Promise(function (resolve1, reject1) {
return new Promise(function (resolve2, reject2) { |
In that search there is actually only 5 occurrences of the pattern, most was some type of testing code that did |
@rstacruz Regardless if this should be caught, I suspect that's generally done by authors that lack understanding of how closures work. e.g. In the first example |
Is there even an eslint rule to enforce this with? |
+1 to this. I made an eslint plugin for this rule, https://github.com/jden/eslint-plugin-promiseparams |
@jden Awesome! 👍 |
re @rstacruz's example return new Promise(function (resolve1, reject1) {
return new Promise(function (resolve2, reject2) { this is never necessary because of closure scoping. It doesn't make sense for an inner promise to resolve or reject an outer promise. I suppose it's possible to contrive some example that is a valid JavaScript program, but it's a confusing style which breaks the wrapper abstraction of promises in favor of cross-scope shared state with the added dimension of asynchronous execution time - exactly the sort of unnecessarily complex and unusual code style that an opinionated linter can protect you from. |
This makes sense to me. Thanks for putting together the rule @jden! |
Is |
@jden Yeah there is at least one custom plugin. Submit this to https://github.com/feross/eslint-config-standard |
This is 👍 from me. Let's ship it in |
|
@feross that is quite surprising! Good to see people are consistent 👍 |
- Allow users to set the per_page option to 0 - 0.1.3 released - bugfix for archive disabled pagination when archive disabled pagination, per_page should be 0. - fix typo - Merge pull request #1 from wileam/patch-1 bugfix for archive disabled pagination - add archive daily - add tests - Merge pull request #2 from huanz/master add archive daily - Replace JSHint with ESLint and JSCS - 0.1.4 released - Fix: cannot deploy when src refspec is not master - Use HEAD src refspec to fix the problem - Merge pull request #4 from h404bi/master Fix: cannot deploy when src refspec is not master - Update README.md Clarify `branch` option - Use ESLint and JSCS - Set global git config for CI - 0.1.0 released - Allow users to set the per_page option to 0 - Merge pull request #2 from borisschapira/master Allow users to set the per_page option to 0 - 0.1.3 released - Set scrolling="no" to make iframe responsive the fiddle iframe is not responsive in iOS safari and Chrome. By setting `scrolling="no"` makes it possible to fix this issue, by setting `width=1px; min-width=100%` in CSS. [See StackOverflow](http://stackoverflow.com/questions/23083462/how-to-get-an-iframe-to-be-responsive-in-ios-safari) - fixed #1105 - Merge pull request #1345 from anjianshi/master fixed #1105 make url_for() handle "/" correctly - New date helper using momentjs 'fromNow' method Moment.js provides a quite useful function for relative time, it would be a shame not to use it ;) - Explicit comparisons - Do not compare undefined with null, explicit the cas instead - Decorrelate fromNow from output - date_fromNow tests - Now there is a function that apply locale and timezone and each helper format the date - [helper] add log() Good for logging objects in theme and plugin originally #1389 Changes to be committed: modified: lib/plugins/helper/debug.js modified: lib/plugins/helper/index.js new file: test/scripts/helpers/debug.js modified: test/scripts/helpers/index.js - Merge pull request #1391 from leesei/master [helper] add log() - Prepend root path to urlForHelper When user configures a prefix path as root path, urlForHelper can not resolve url like '/archives' correctly with the prefix root path. Resolves: #1105 - Merge pull request #1406 from liuhongjiang/add_root_to_urlForHelper Prepend root path to urlForHelper - now hexo list post will show category and tag what post been - add hexo list category(cate) - fix CI error - Modify the error Modify tag_id to category_id in line 153. - Use ESLint and JSCS instead of JSHint. Fix tests failed on Node.js 4 - Fix coding style - Add contributing guide - fix: #1451: more cannot work in almost all themes - fix "date" attribute default value - fix relative_url - fix: #1451: more cannot work in almost all themes - Merge branch 'fix_more_excerpt' of https://github.com/amobiz/hexo into HEAD - added line_number flag to code block, allowing for independent enabling/disabling of line numbers for each block - restricted trimming of tag bodies to the (presumably intended) cleaning up of occasionally parser-inserted extraneous line breaks. - added test - Merge pull request #1539 from aausch/correct_tag_trimming Correct tag trimming - might as well add a configuration option to enable/disable highlight all together. - unit test for highlight disable option - unit test for line_number option. - Fix https warning When blog is on https, there is warning if all resources are not on https... - Fix HTML issue with RSS/Atom feeds: rel="alternate" According to the W3C, "alternative" is not a valid value for attribute "rel" on element "link". The HTML5 standard uses <link rel="alternate" to provide an alternate representation, such as RSS or Atom. - Merge pull request #1572 from vhf/feed-tag-fix Fix HTML issue with RSS/Atom feeds: rel="alternate" - Merge pull request #1561 from nemanjan00/patch-1 Fix https warning - Merge pull request #1524 from zoubin/bugfix-relative_url fix relative_url - Merge pull request #1519 from amobiz/fix_more_excerpt Fix more excerpt - Fix gravatar helper tests failed and update deps - Merge pull request #1538 from aausch/block_configurable_line_numbers override line_number, highlight settings at the codeblock level - Merge pull request #1512 from Gtskk/patch-1 Modify the error - Merge pull request #1523 from aulphar/master fix "date" attribute default value #1522 - Merge branch 'master' of https://github.com/XGHeaven/hexo into XGHeaven-master # Conflicts: # lib/plugins/console/list/post.js - Merge branch 'XGHeaven-master' - Make JSCS happy - Fix the issue that we cannot use space in tag parameter which wrapped with double quote mark - fix the syntax warning - Fix the issue of jscs error - Fix post list console - Add abbrev. support for list console - Update hero-util to 0.2.1 - Merge branch 'master' of https://github.com/borisschapira/hexo into borisschapira-master # Conflicts: # lib/plugins/helper/date.js # test/scripts/helpers/date.js - Rename date_fromNow helper to relative_date - Disable auto detect for highlight by default - Replace sha1 with xxHash for faster checksum - Lazy load file hash - Load file hash only if the file is new or the modified time is changed - Lock the file when resolving the cache - Use g++-4.8 on Travis. Remove Node.js 0.10 build and add Node.js 5. - Use xxhash as optional dependency - Update warehouse to 2.0.0 - Detect the current category/tag in `is_category/tag` helper. Resolve #1278 - Fix Sha1Stream return raw buffer - Always use xxhash - 3.2.0-beta.1 released - tag: fix special tag names - jscs --fix - add option for first line number to tag.js - add option for first line number to test - delete extra blank line. - Use Promise.each in box process to prevent race condition - Use eslint-plugin-hexo and jscs-preset-hexo - Speed improvements Changes: - Rewrite Box. - Process files during loading file list. - Delay file hash check. Use File.changed() to check if file changed. - Remove watch delay. - Parallel processing. - Save rendered content in warehouse. It really saves a lot of time. - Rewrite generate console. - Cache rendered content so we don't have to render it again. - Load file list from cache. Don't delete other files in public folder. Resolve #1310 - Remove file stat check. - Parallel generating. - Resolve race conditions. Known issues: - Parallel processing and parallel generating may cause race conditions. We have to solve this in warehouse. - Tests are not updated yet. - Merge pull request #1607 from rhykw/add-firstLine-option-to-tag-plugin Added `first_line` option to codeblock - Merge pull request #1599 from magicdawn/fix-special-tags tag: fix special tag names - Merge pull request #1305 from tjwudi/master Set scrolling="no" to make iframe responsive - Merge pull request #1581 from winterTTr/master Fix issue cannot correctly analyze arguments with space in tag - Fix box tests. Emit processBefore & processAfter on Box instead of Hexo context. - Bug fixes. - Fix all other tests. - Listen to processAfter event of boxes. - Fix generate console not write file if not exist - Allow non-json file in data processor - Remove post asset if post was removed - Update [email protected] and fix box tests on Linux - Merge branch 'new-box' - Fix JSCS error - Ignore node_modules folder in theme folder. Resolve #1316 - Implement include/exclude files - Merge config instead of extend - 3.2.0-beta.2 released - 解决code中存在类似swig语法被错误解析的问题 - Add headerlink for post render test cases - Update hexo-renderer-marked version - Ignore milliseconds for the post test cases - Fix cache key name error for box file test cases - Merge pull request #1668 from liuhongjiang/fix-test-errors Fix test errors - Merge pull request #1652 from ksky521/master 解决code中存在类似swig语法被错误解析的问题 - Support root path configure for img tag Current img tag doesn't prepend root path if it's not a slash. With this fix, the root path will be prepend to the img src if it's not a slash. This fix only works for the hexo tags, does not work for the markdown syntax of links and images. The issues of markdown links and images should be fixed in the hexo-renderer-marked module. Resolves: #1440 - Add root path to permalink of post This commit fixs this problem, when the root path is set to a subdirectory, there is no this root path in the permalink of post. - Merge pull request #1444 from liuhongjiang/prepend-root-to-img-tag Support root path configure for img tag - OpenGraph: added support for twitter image attribute - trim() instead of regular expression - keywords supported in open_graph - Update license date - Merge pull request #1697 from timwangdev/patch-2 Happy new year! - Remove unneccessary refs to type attr in helper output snippets. See Issue #1695: hexojs/hexo#1695 Also see the HTML5 Spec section on the type attr: http://dev.w3.org/html5/spec-preview/Overview.html#attr-link-type In short, the use of type tags is purely advisory, and the spec instructs browsers to infer the resource type before fetching them. In cases where the inference does not match the declaration, the resource will not be loaded. When the declaration is left off, the resource will load. It appears generally safer to leave the tags off entirely. - Revise tests to not expect type attrs in generated link/script tags. - url_for helper: Don't prepend root if url is started with # Fix #1708 - Ignore empty categories/tags. Fix #1704 - Fix skip_render doesn't work in asset generator - Allow specify plugin list in config. Resolve #1670 - Merge pull request #1706 from brycepj/1695-html5-type-remove Remove unneccessary refs to type attr in helper output snippets - Merge pull request #1681 from giuseppelt/giuseppelt-og-twitter OpenGraph: added support for twitter image attribute - Merge pull request #1683 from yanni4night/master keywords supported in open_graph - Update deps - Make linter happy - Use hero-log and remove commands exist in hexo-cli - Replace Swig in post.create - Remove bunyan - Add tests for config console - Update debug helper test with rewire - Update appveyor.yml - View render improvements - Use _.assign instead of _.extend - Simplify View.prototype._buildLocals - Precompile theme templates if possible - Update dependencies - Fix category path when placed on root This patch fixes the double slashes (http://site.com//cat1) in the category path, when you configure `category_dir` with '/' or '' - Merge branch 'giuseppelt-patch-1' - [fix] don't urlescape path of post asset fixes #1562 Changes to be committed: modified: lib/models/post_asset.js modified: test/scripts/tags/asset_img.js - [test] add spaced asset test for all post asset tags Changes to be committed: modified: test/scripts/tags/asset_img.js modified: test/scripts/tags/asset_link.js modified: test/scripts/tags/asset_path.js - [chore] make linter happy - [test] add test for number of lines in code block Changes to be committed: modified: test/scripts/tags/code.js - test(processor/post): should compare with birthtime - add mark option to code blocks closes #1766 - test(tags/code): update mark test Changes to be committed: modified: test/scripts/tags/code.js - lint(tags/code): make linter happy Changes to be committed: modified: lib/plugins/tag/code.js modified: test/scripts/tags/code.js - Load file status before Box.process - Remove File.changed method - There's no big difference to load file status in demand so I bring back file type "skip". - Fix tests failed on Windows since the incorrect path separator - Add test for Swig template compile - 3.2.0 released - fixes hexojs/hexo#1297 - Merge pull request #1 from borisschapira/master fixes hexojs/hexo#1297 - 0.1.3 released - Custom order for posts - Update README - Merge pull request #3 from iissnan/order-customization Custom order for posts - Replace JSHint with ESLint and JSCS - 0.2.0 released - Allow users to set the per_page option to 0 - Merge pull request #1 from borisschapira/master Allow users to set the per_page option to 0 - 0.1.2 released - allow to generate tag index page - update test for tag index page - Merge pull request #2 from creeperyang/AddIndexPage Add Tag index page - Use eslint-config-hexo and jscs-preset-hexo - 0.2.0 released - Add tests - 0.1.1 released - Add support for template precompile - 0.2.0 released - Use opn instead. Don't watch files in static mode. - Use eslint-config-hexo and jscs-preset-hexo - added process.env.port to facilitate configuration through process management utils (pm2/strongloop/forever/heroku). follows express convention - Merge pull request #16 from EvanCarroll/master added process.env.port to facilitate configuration through process ma… - 0.1.3 released - Update appveyor.yml - Add options and some improvements - Add "compress" option: Enable GZIP compression - Add "header" option: Add "X-Powered-By: Hexo" header - Display "0.0.0.0" as "localhost" - Use supertest-promised in tests - Make linter happy - Install superset as well - 0.2.0 released - Update readme - Upgrade dependencies. Fixes DoS in marked. Closes #3 - Merge pull request #14 from rstoenescu/master Upgrade dependencies. Fixes DoS in marked. - headerlink - mocha test error fix - Merge pull request #15 from ksky521/master headerlink - Use eslint-config-hexo and jscs-preset-hexo - 0.2.6 released - Strip html from headerlink title - add unit test for header links - Merge pull request #17 from cgmartin/patch-1 Strip html from headerlink title - 0.2.7 released - Prepend root path to img and link In hexo configuration, if the root path is set to a sub directory, hexo should prepend this root path to img and link of markdown syntax. Resolves: hexojs/hexo#1440 - Merge pull request #7 from liuhongjiang/prepend-root-to-img-link Prepend root path to img and link - 0.2.8 released - No prefix for anchor links Inserting links to headings directly from markdown is common practice. `[jump to title](#title)` should not become a full-blown URL on markdown rendering. It should instead be rendered as-is: `<a href="#title">jump to title</a>`. - Merge pull request #21 from vhf/no-prefix-for-anchor-links No prefix for anchor links - Don't prepend root path to links - 0.2.9 released - Use slugize method of hexo-util to fix Chinese headers can't be handle properly - 0.2.10 released - travis: add 4.0.0 - Merge pull request #16 from feross/dcousens-patch-1 travis: add 4.0.0 - badges - remove `browser: false` env option no-op - Relax radix rule Rule: http://eslint.org/docs/rules/radix.html Just tested latest Chrome, Firefox, Safari, and Edge and parseInt('071') returns 71 as expected. I think we can finally relax this rule. Code that uses parseInt and targets really old browsers should still use a radix, but this doesn't need to be a rule anymore. Discussion: standard/standard#384 - code style - BREAKING: require eslint 2.0.0 - config changes for eslint 2.0.0 - no-return-assign: make default option explicit - disallow label usage, even with loops/switch statements - fix config validation issue - New rule: Enforce spaces around * in "yield *" http://eslint.org/docs/2.0.0/rules/yield-star-spacing Fixes standard/standard#335 - enable jsx support for standard 6 standard v6 will not use the eslint sharable config “eslint-config-standard-react” anymore. So, let’s add support for jsx syntax in the parser in eslint-config-standard. Discussion: standard/standard#351 - travis: drop 0.10 and 0.12 support - New rule: Require parens in arrow function arguments http://eslint.org/docs/2.0.0/rules/arrow-parens.html Fixes standard/standard#309 - alphabetize package.json keywords - add promise/param-names rule Ensures that new Promise() is instantiated with the parameter names resolve, reject. Fixes standard/standard#282 - remove duplicate rule - New rule: Enforce Usage of Spacing in Template Strings (template-curly-spacing) http://eslint.org/docs/2.0.0/rules/template-curly-spacing - New rule: Disallow Symbol Constructor (no-new-symbol) http://eslint.org/docs/2.0.0/rules/no-new-symbol - New rule: Disallow Self Assignment (no-self-assign) http://eslint.org/docs/2.0.0/rules/no-self-assign - New rule: Disallow unnecessary constructor (no-useless-constructor) http://eslint.org/docs/2.0.0/rules/no-useless-constructor - New rule: Disallow string concatenation when using __dirname and __filename (no-path-concat) Fixes #403 http://eslint.org/docs/2.0.0/rules/no-path-concat - New rule: Disallow empty destructuring patterns (no-empty-pattern) http://eslint.org/docs/2.0.0/rules/no-empty-pattern - move jsx-quotes rule from eslint-config-standard-react - readme - test: fix for eslint 2 - 5.0.0 - fix tests - lock to latest versions - peer depend on eslint - 5.1.0 - Appveyor yml file - remove unnecessary options object manipulation - v6.0.2 - Revert "remove unnecessary options object manipulation" This reverts commit eb6319ff50ae8ef4f9f287fdd4d8f67ba083bba2. Turns out those options ARE relevant, for Minimatch, though not for glob. Oh well. Fix #239 - v6.0.3 - update badges to add appveyor and coveralls remove david-dm, since I don't really get much value out of it. I run 'npm outdated' enough to find issues. - add node 5 to travis-ci - simplify appveyor.yml file Also adds a few details that make things go faster - Upgrade to tap@4 Required a slight change since Istanbul now includes a fs.readdirSync(), which triggered the ENOTSUP test monkeypatch. - Fix appveyor install of node Thanks @appveyor support! - remove util._extend fix #240 - tap@5 - v6.0.4 - Raise error if cwd is not a directory Fix #235 - v7.0.0 - add package name to readme Fix #230 - changelog Fix #179 - Fix race condition when all patterns are ignored Fix #232 - v7.0.1 - Properly exclude dirs using nodir when root is set Fix #221 - update tap to 5.7.0 - v7.0.2 - test: fix some paths for windows - remove incorrect absolute-ness check in makeAbs - Prevent incorrect nodir results on Windows Ensure that everything in the cache always uses correct slashes, and always test against absolute paths when checking anything in the cache. - optimization: only abs the cwd once - v7.0.3
One common problem that often hits me when dealing with promises is in what order the parameters are in the executor.
Is it
resolve, reject
orreject, resolve
? The correct answer is the first one, but wouldn't it be awesome ifstandard
forced this for you? It's kind of how we force you to handle the first parameter if it's namederr
.Sounds good? 🎢
The text was updated successfully, but these errors were encountered: