fix: ignore spacing before ] and } in comma-spacing#16113
Merged
Conversation
This avoids conflicts with array-bracket-spacing and object-curly-spacing rules. Fixes #16100
✅ Deploy Preview for docs-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
mdjermanovic
commented
Jul 7, 2022
Comment on lines
-201
to
-211
| { | ||
| code: "var arr = [1 , ];", | ||
| output: "var arr = [1 ,];", | ||
| options: [{ before: true, after: false }], | ||
| errors: [ | ||
| { | ||
| message: "There should be no space after ','.", | ||
| type: "Punctuator" | ||
| } | ||
| ] | ||
| }, |
Member
Author
There was a problem hiding this comment.
This was conflicting with array-bracket-spacing option "always" on the right side of ,.
crapStone
pushed a commit
to Calciumdibromid/CaBr2
that referenced
this pull request
Jul 18, 2022
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [eslint](https://eslint.org) ([source](https://github.com/eslint/eslint)) | devDependencies | minor | [`8.19.0` -> `8.20.0`](https://renovatebot.com/diffs/npm/eslint/8.19.0/8.20.0) | --- ### Release Notes <details> <summary>eslint/eslint</summary> ### [`v8.20.0`](https://github.com/eslint/eslint/releases/tag/v8.20.0) [Compare Source](eslint/eslint@v8.19.0...v8.20.0) #### Features - [`ca83178`](eslint/eslint@ca83178) feat: catch preprocess errors ([#​16105](eslint/eslint#16105)) (JounQin) #### Bug Fixes - [`30be0ed`](eslint/eslint@30be0ed) fix: no-warning-comments rule escapes special RegEx characters in terms ([#​16090](eslint/eslint#16090)) (Lachlan Hunt) - [`bfe5e88`](eslint/eslint@bfe5e88) fix: ignore spacing before `]` and `}` in comma-spacing ([#​16113](eslint/eslint#16113)) (Milos Djermanovic) #### Documentation - [`845c4f4`](eslint/eslint@845c4f4) docs: Add website team details ([#​16115](eslint/eslint#16115)) (Nicholas C. Zakas) - [`5a0dfdb`](eslint/eslint@5a0dfdb) docs: Link to blog post in no-constant-binary-expression ([#​16112](eslint/eslint#16112)) (Jordan Eldredge) - [`bc692a9`](eslint/eslint@bc692a9) docs: remove install command ([#​16084](eslint/eslint#16084)) (Strek) - [`49ca3f0`](eslint/eslint@49ca3f0) docs: don't show toc when content not found ([#​16095](eslint/eslint#16095)) (Amaresh S M) - [`ba19e3f`](eslint/eslint@ba19e3f) docs: enhance 404 page UI ([#​16097](eslint/eslint#16097)) (Amaresh S M) - [`a75d3b4`](eslint/eslint@a75d3b4) docs: remove unused meta.docs.category field in working-with-rules page ([#​16109](eslint/eslint#16109)) (Brandon Scott) - [`cdc0206`](eslint/eslint@cdc0206) docs: add formatters page edit link ([#​16094](eslint/eslint#16094)) (Amaresh S M) - [`4d1ed22`](eslint/eslint@4d1ed22) docs: preselect default theme ([#​16098](eslint/eslint#16098)) (Strek) - [`4b79612`](eslint/eslint@4b79612) docs: add missing correct/incorrect containers ([#​16087](eslint/eslint#16087)) (Milos Djermanovic) - [`09f6acb`](eslint/eslint@09f6acb) docs: fix UI bug on rules index and details pages ([#​16082](eslint/eslint#16082)) (Deepshika S) - [`f5db264`](eslint/eslint@f5db264) docs: remove remaining duplicate rule descriptions ([#​16093](eslint/eslint#16093)) (Milos Djermanovic) - [`32a6b2a`](eslint/eslint@32a6b2a) docs: Add scroll behaviour smooth ([#​16056](eslint/eslint#16056)) (Amaresh S M) #### Chores - [`bbf8df4`](eslint/eslint@bbf8df4) chore: Mark autogenerated release blog post as draft ([#​16130](eslint/eslint#16130)) (Nicholas C. Zakas) - [`eee4306`](eslint/eslint@eee4306) chore: update internal lint dependencies ([#​16088](eslint/eslint#16088)) (Bryan Mishkin) - [`9615a42`](eslint/eslint@9615a42) chore: update formatter examples template to avoid markdown lint error ([#​16085](eslint/eslint#16085)) (Milos Djermanovic) - [`62541ed`](eslint/eslint@62541ed) chore: fix markdown linting error ([#​16083](eslint/eslint#16083)) (唯然) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTcuMSIsInVwZGF0ZWRJblZlciI6IjMyLjExNy4xIn0=--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1466 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
Fixes #16100
Updates the
comma-spacingrule to ignore spacing before]and spacing before}in order to avoid conflicts witharray-bracket-spacingandobject-curly-spacingrules.For example, the current version of
comma-spacingreports an error on each of the following lines, but fixing them triggers errors fromarray-bracket-spacingandobject-curly-spacingrules:Playground link
Note that this rule already ignores spacing after
[(#3392) and spacing before)(#11295).What changes did you make? (Give an overview)
validateCommaItemSpacinginto the loop in"Program:exit"()because the logic of what to check and what to ignore was unnecessarily scattered.JSXTextcheck. We are checking if it's a comma punctuator token just a line before, so it can't be JSXText.]and}.Is there anything you'd like reviewers to focus on?
I also wanted to replace
addNullElementsToIgnoreListand all related code with a simple[token check, but it turned out that the existing logic has possibly unintentional side effects of ignoring spacing between a comment and ending comma of a hole/elision.