Skip to content

Commit 7cd91b8

Browse files
authored
empty-brace-spaces: Remove support for RecordExpression (#2629)
1 parent 756dbbf commit 7cd91b8

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

rules/empty-brace-spaces.js

+4-16
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ const messages = {
77

88
const getProblem = (node, context) => {
99
const {sourceCode} = context;
10-
const filter = node.type === 'RecordExpression'
11-
? token => token.type === 'Punctuator' && (token.value === '#{' || token.value === '{|')
12-
: isOpeningBraceToken;
13-
const openingBrace = sourceCode.getFirstToken(node, {filter});
10+
const openingBrace = sourceCode.getFirstToken(node, {filter: isOpeningBraceToken});
1411
const closingBrace = sourceCode.getLastToken(node);
1512
const [, start] = sourceCode.getRange(openingBrace);
1613
const [end] = sourceCode.getRange(closingBrace);
@@ -36,20 +33,11 @@ const create = context => {
3633
'BlockStatement',
3734
'ClassBody',
3835
'StaticBlock',
39-
], node => {
40-
if (node.body.length > 0) {
41-
return;
42-
}
43-
44-
return getProblem(node, context);
45-
});
46-
47-
context.on([
4836
'ObjectExpression',
49-
// Experimental https://github.com/tc39/proposal-record-tuple
50-
'RecordExpression',
5137
], node => {
52-
if (node.properties.length > 0) {
38+
const children = node.type === 'ObjectExpression' ? node.properties : node.body;
39+
40+
if (children.length > 0) {
5341
return;
5442
}
5543

test/empty-brace-spaces.js

-12
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,6 @@ test.babel({
114114
languageOptions: enableBabelPlugin('doExpressions'),
115115
errors: 1,
116116
},
117-
{
118-
code: 'const record = #{ };',
119-
output: 'const record = #{};',
120-
languageOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'hash'}]),
121-
errors: 1,
122-
},
123-
{
124-
code: 'const record = {| |};',
125-
output: 'const record = {||};',
126-
languageOptions: enableBabelPlugin(['recordAndTuple', {syntaxType: 'bar'}]),
127-
errors: 1,
128-
},
129117
{
130118
code: outdent`
131119
class Foo {

0 commit comments

Comments
 (0)