From 3d98c3a12ae68d18efee188aa3379419e9cf58e0 Mon Sep 17 00:00:00 2001 From: Martin Cura Date: Fri, 24 May 2019 16:07:00 -0300 Subject: [PATCH 1/2] JSX decreaseIndentForNextLine: ignore single closing bracket Follow eslint rule jsx-closing-bracket-location [1] by not decreasing indent on a lonely closing bracket. More info in PR. [1] https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md --- lib/atom-react.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/atom-react.coffee b/lib/atom-react.coffee index b16f169..40e77d3 100644 --- a/lib/atom-react.coffee +++ b/lib/atom-react.coffee @@ -8,7 +8,7 @@ autoCompleteTagCloseRegex = /(<\/)([^>]+)(>)/g jsxTagStartPattern = '(?x)((^|=|return)\\s*<([^!/?](?!.+?())))' jsxComplexAttributePattern = '(?x)\\{ [^}"\']* $|\\( [^)"\']* $' decreaseIndentForNextLinePattern = '(?x) -/>\\s*(,|;)?\\s*$ +\\S+\\s*/>\\s*(,|;)?\\s*$ | ^(?!\\s*\\?)\\s*\\S+.*$' class AtomReact @@ -252,7 +252,7 @@ class AtomReact options = {undo: 'skip'} else options = {} - + editor.insertText('', options) editor.setCursorBufferPosition(eventObj.newRange.end) From aaa476529ac65343cd60f147d6a67a50a742a4b2 Mon Sep 17 00:00:00 2001 From: Martin Cura Date: Fri, 24 May 2019 16:34:25 -0300 Subject: [PATCH 2/2] Decrease indent for single closing bracket: jsx-closing-bracket-location Decrease the indentation when inserting simply '/>', so that in the flow of typing it aligns with the opening bracket for a multi-line self-closing element. Check PR for more info. --- settings/JavaScript (JSX).cson | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/JavaScript (JSX).cson b/settings/JavaScript (JSX).cson index 7b1a44a..923c680 100644 --- a/settings/JavaScript (JSX).cson +++ b/settings/JavaScript (JSX).cson @@ -10,6 +10,7 @@ | \\( [^)"\']* $' 'decreaseIndentPattern': '(?x) ^\\s*(\\s*(,|;)?\\s*$ | ^ \\s* (\\s* /[*] .* [*]/ \\s*)* [}\\])]' '.source.js.jsx .tag:not(.entity.other.attribute-name, .entity.name.tag, .punctuation.definition.tag.begin, .invalid.illegal.incomplete .string, .curly)':