-
Notifications
You must be signed in to change notification settings - Fork 597
[JavaScript] Code and Data specific indentation rules #4015
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
Merged
FichteFoll
merged 14 commits into
sublimehq:master
from
deathaxe:pr/javascript/fix-indentation
Aug 30, 2024
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0130c22
[JavaScript] Exclude mappings from normal keyword indentation
deathaxe 39a5f4d
[JavaScript] Exclude lists from normal keyword indentation
deathaxe b7b7106
[JavaScript] Add key binding for bracket content auto-indentation
deathaxe b4d864f
[JavaScript] Handle function calls in mappings or lists
deathaxe edac170
[JavaScript] Reorganize tests
deathaxe 0bd0f97
[JavaScript] Add tests for embedded JS code blocks
deathaxe d374fc6
[JavaScript] Remove failing tests
deathaxe eec9dc7
[JavaScript] Rename indentation rules file
deathaxe d60cbc0
Merge branch 'master' into pr/javascript/fix-indentation
deathaxe 3eb4798
Merge branch 'master' into pr/javascript/fix-indentation
deathaxe d237d2f
[JavaScript] Improve indentation rules of tagged template strings
deathaxe 67d86e6
[JavaScript] Tweak key binding context key order
deathaxe a644c0e
[JavaScript] Tweak enter key binding
deathaxe dfad440
[JavaScript] Simplify indentation rules
FichteFoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>scope</key> | ||
| <string> | ||
| (source.js meta.mapping, source.js meta.sequence) - source.js meta.function, | ||
| source.js meta.function meta.mapping, | ||
| source.js meta.function meta.sequence, | ||
| (source.jsx meta.mapping, source.jsx meta.sequence) - source.jsx meta.function, | ||
| source.jsx meta.function meta.mapping, | ||
| source.jsx meta.function meta.sequence, | ||
| (source.ts meta.mapping, source.ts meta.sequence) - source.ts meta.function, | ||
| source.ts meta.function meta.mapping, | ||
| source.ts meta.function meta.sequence, | ||
| (source.tsx meta.mapping, source.tsx meta.sequence) - source.tsx meta.function, | ||
| source.tsx meta.function meta.mapping, | ||
| source.tsx meta.function meta.sequence | ||
| </string> | ||
| <key>settings</key> | ||
| <dict> | ||
| <!-- NOTE: Keep in sync with JSON! --> | ||
| <key>decreaseIndentPattern</key> | ||
| <string>(?x) | ||
| # When an object is closed, but not opened | ||
| ( | ||
| ^ | ||
| ( | ||
| # Consume strings | ||
| "(?:[^"\\]|\\.)*" | ||
| | | ||
| # Consume all chars that don't start a string, comment or | ||
| # open an object on this line | ||
| [^"/{\n] | ||
| )* | ||
| \}.*$ | ||
| ) | ||
| | | ||
| # When an array is closed by itself on a line (interacts with indentSquareBrackets) | ||
| ( | ||
| ^(.*\*/)?\s*\].*$ | ||
| ) | ||
| </string> | ||
| <key>increaseIndentPattern</key> | ||
| <string>(?x) | ||
| # When an object is opened, but not closed | ||
| ( | ||
| ^.*\{ | ||
| ( | ||
| # Consume strings | ||
| "(?:[^"\\]|\\.)*" | ||
| | | ||
| # Consume all chars that don't start a string, comment or | ||
| # end the object that was opened on this line | ||
| [^"/}] | ||
| )* | ||
| # Stop matching at the end of the line, or once we hit a comment | ||
| ($|/[/*]) | ||
| ) | ||
| | | ||
| # When an array is opened, but not closed | ||
| ( | ||
| ^.*\[ | ||
| ( | ||
| # Consume strings | ||
| "(?:[^"\\]|\\.)*" | ||
| | | ||
| # Consume all chars that don't start a string, comment or | ||
| # end the array that was opened on this line | ||
| [^"/\]] | ||
| )* | ||
| # Stop matching at the end of the line, or once we hit a comment | ||
| ($|/[/*]) | ||
| ) | ||
| </string> | ||
| </dict> | ||
| </dict> | ||
| </plist> |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // SYNTAX TEST reindent-unchanged "Packages/Markdown/Markdown.sublime-syntax" | ||
|
|
||
| ```js | ||
| export default { | ||
| default: 'value', | ||
| case() { | ||
| const map1 = { | ||
| default: 'value' | ||
| } | ||
| const list1 = [ | ||
| default | ||
| ] | ||
|
|
||
| if (foo == true) | ||
| return 1 | ||
| else if (bar == true) | ||
| return 2 | ||
| else | ||
| return 3 | ||
|
|
||
| switch (map1) { | ||
| case null: | ||
| return 0 | ||
| default: | ||
| const map2 = { | ||
| default: 'value' | ||
| } | ||
| const list2 = [ | ||
| default, | ||
| () => { | ||
| switch (map2) { | ||
| default: | ||
| return 0 | ||
| case null: | ||
| return 1 | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // SYNTAX TEST reindent-unchanged "Packages/PHP/PHP.sublime-syntax" | ||
|
|
||
| <?php | ||
| $var = <<<JAVASCRIPT | ||
| export default { | ||
| default: 'value', | ||
| case() { | ||
| const map1 = { | ||
| default: 'value' | ||
| } | ||
| const list1 = [ | ||
| default | ||
| ] | ||
|
|
||
| if (foo == true) | ||
| return 1 | ||
| else if (bar == true) | ||
| return 2 | ||
| else | ||
| return 3 | ||
|
|
||
| switch (map1) { | ||
| case null: | ||
| return 0 | ||
| default: | ||
| const map2 = { | ||
| default: 'value' | ||
| } | ||
| const list2 = [ | ||
| default, | ||
| () => { | ||
| switch (map2) { | ||
| default: | ||
| return 0 | ||
| case null: | ||
| return 1 | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| JAVASCRIPT |
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.
Uh oh!
There was an error while loading. Please reload this page.