Skip to content

Commit b0477b2

Browse files
committed
Merge branch 'SimeonC-fix-interface-delimiters'
2 parents 2981c01 + f627743 commit b0477b2

File tree

93 files changed

+2577
-2546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2577
-2546
lines changed

.README/rules/delimiter-dangle.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ _The `--fix` option on the command line automatically fixes problems reported by
44

55
Enforces consistent use of trailing commas in Object and Tuple annotations.
66

7-
This rule takes one argument which mirrors ESLint's default `comma-dangle` rule.
7+
This rule takes two arguments which both mirror ESLint's default `comma-dangle` rule.
8+
The first argument is for Object and Tuple annotations.
9+
The second argument is used for Interface annotations as ESLint's default `comma-dangle` doesn't apply to interfaces - this defaults to whatever the first argument is.
810

911
If it is `'never'` then a problem is raised when there is a trailing comma.
1012

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@ _The `--fix` option on the command line automatically fixes problems reported by
604604
605605
Enforces consistent use of trailing commas in Object and Tuple annotations.
606606
607-
This rule takes one argument which mirrors ESLint's default `comma-dangle` rule.
607+
This rule takes two arguments which both mirror ESLint's default `comma-dangle` rule.
608+
The first argument is for Object and Tuple annotations.
609+
The second argument is used for Interface annotations as ESLint's default `comma-dangle` doesn't apply to interfaces - this defaults to whatever the first argument is.
608610
609611
If it is `'never'` then a problem is raised when there is a trailing comma.
610612
@@ -660,6 +662,10 @@ foo: string
660662
type X = { foo: string; }
661663
// Message: Unexpected trailing delimiter
662664

665+
// Options: ["always","never"]
666+
interface X { foo: string; }
667+
// Message: Unexpected trailing delimiter
668+
663669
// Options: ["never"]
664670
type X = { [key: string]: number, }
665671
// Message: Unexpected trailing delimiter
@@ -862,6 +868,9 @@ type X = {
862868
foo: string;
863869
}
864870

871+
// Options: ["never","always"]
872+
interface X { foo: string; }
873+
865874
// Options: ["never"]
866875
type X = {}
867876

@@ -1152,7 +1161,7 @@ import Foo from './foo';
11521161
// Message: Expected newline after flow annotation
11531162

11541163
// Options: ["always-windows"]
1155-
// @flow
1164+
// @flow
11561165
import Foo from './foo';
11571166
// Message: Expected newline after flow annotation
11581167

@@ -1172,8 +1181,8 @@ The following patterns are not considered problems:
11721181
import Foo from './foo';
11731182

11741183
// Options: ["always-windows"]
1175-
// @flow
1176-
1184+
// @flow
1185+
11771186
import Foo from './foo';
11781187

11791188
// Options: ["never"]
@@ -4028,7 +4037,7 @@ The following patterns are not considered problems:
40284037
{ a: string, b: number }) => {}
40294038
40304039
// Options: ["always",{"allowLineBreak":true}]
4031-
(foo:
4040+
(foo:
40324041
{ a: string, b: number }) => {}
40334042
40344043
// Options: ["never"]

src/bin/addAssertions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const getAssertions = () => {
4848

4949
return {
5050
invalid: _.map(codes.invalid, formatCodeSnippet),
51-
valid: _.map(codes.valid, formatCodeSnippet),
51+
valid: _.map(codes.valid, formatCodeSnippet)
5252
};
5353
});
5454

src/bin/checkDocs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import fs from 'fs';
66
import path from 'path';
77
import {
88
getRules,
9-
isFile,
9+
isFile
1010
} from './utilities';
1111

1212
const windows = (array, size) => {

src/bin/checkTests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import fs from 'fs';
44
import path from 'path';
55
import {
66
getRules,
7-
isFile,
7+
isFile
88
} from './utilities';
99

1010
const getTestIndexRules = () => {
@@ -24,7 +24,7 @@ const getTestIndexRules = () => {
2424
return acc;
2525
}, {
2626
inRulesArray: false,
27-
rules: [],
27+
rules: []
2828
});
2929

3030
const rules = result.rules;

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ const rules = {
7878
'type-import-style': typeImportStyle,
7979
'union-intersection-spacing': unionIntersectionSpacing,
8080
'use-flow-type': useFlowType,
81-
'valid-syntax': validSyntax,
81+
'valid-syntax': validSyntax
8282
};
8383

8484
export default {
8585
configs: {
86-
recommended,
86+
recommended
8787
},
8888
rules: _.mapValues(rules, (rule, key) => {
8989
if (key === 'no-types-missing-file-annotation') {
@@ -92,7 +92,7 @@ export default {
9292

9393
return {
9494
...rule,
95-
create: _.partial(checkFlowFileAnnotation, rule.create),
95+
create: _.partial(checkFlowFileAnnotation, rule.create)
9696
};
9797
}),
9898
rulesConfig: {
@@ -123,6 +123,6 @@ export default {
123123
'type-import-style': 0,
124124
'union-intersection-spacing': 0,
125125
'use-flow-type': 0,
126-
'valid-syntax': 0,
127-
},
126+
'valid-syntax': 0
127+
}
128128
};

src/rules/arrayStyle/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import needWrap from './needWrap';
44
const schema = [
55
{
66
enum: ['verbose', 'shorthand'],
7-
type: 'string',
8-
},
7+
type: 'string'
8+
}
99
];
1010

1111
const inlineType = (type) => {
@@ -33,13 +33,13 @@ export default (defaultConfig, simpleType) => {
3333
context.report({
3434
data: {
3535
type: inlinedType,
36-
wrappedType: wrappedInlinedType,
36+
wrappedType: wrappedInlinedType
3737
},
3838
fix (fixer) {
3939
return fixer.replaceText(node, 'Array<' + rawElementType + '>');
4040
},
4141
message: 'Use "Array<{{ type }}>", not "{{ wrappedType }}[]"',
42-
node,
42+
node
4343
});
4444
}
4545
},
@@ -59,7 +59,7 @@ export default (defaultConfig, simpleType) => {
5959
context.report({
6060
data: {
6161
type: inlinedType,
62-
wrappedType: wrappedInlinedType,
62+
wrappedType: wrappedInlinedType
6363
},
6464
fix (fixer) {
6565
if (needWrap(elementTypeNode)) {
@@ -69,17 +69,17 @@ export default (defaultConfig, simpleType) => {
6969
}
7070
},
7171
message: 'Use "{{ wrappedType }}[]", not "Array<{{ type }}>"',
72-
node,
72+
node
7373
});
7474
}
7575
}
7676
}
77-
},
77+
}
7878
};
7979
};
8080

8181
return {
8282
create,
83-
schema,
83+
schema
8484
};
8585
};

src/rules/arrayStyle/isSimpleType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
const simpleTypePatterns = [
2222
/^(?:Any|Array|Boolean|Generic|Mixed|Number|String|Void)TypeAnnotation$/,
23-
/.+LiteralTypeAnnotation$/,
23+
/.+LiteralTypeAnnotation$/
2424
];
2525

2626
export default (node) => {

src/rules/arrowParens.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const getLocation = (node) => {
22
return {
33
end: node.params[node.params.length - 1].loc.end,
4-
start: node.params[0].loc.start,
4+
start: node.params[0].loc.start
55
};
66
};
77

@@ -40,7 +40,7 @@ export default {
4040

4141
return fixer.replaceTextRange([
4242
firstTokenOfParam.range[0],
43-
closingParenToken.range[1],
43+
closingParenToken.range[1]
4444
], `${shouldAddSpaceForAsync ? ' ' : ''}${paramToken.value}`);
4545
};
4646

@@ -70,7 +70,7 @@ export default {
7070
fix: fixParamsWithParenthesis,
7171
loc: getLocation(node),
7272
messageId: 'unexpectedParensInline',
73-
node,
73+
node
7474
});
7575
}
7676

@@ -88,7 +88,7 @@ export default {
8888
},
8989
loc: getLocation(node),
9090
messageId: 'expectedParensBlock',
91-
node,
91+
node
9292
});
9393
}
9494

@@ -107,7 +107,7 @@ export default {
107107
fix: fixParamsWithParenthesis,
108108
loc: getLocation(node),
109109
messageId: 'unexpectedParens',
110-
node,
110+
node
111111
});
112112
}
113113

@@ -125,14 +125,14 @@ export default {
125125
},
126126
loc: getLocation(node),
127127
messageId: 'expectedParens',
128-
node,
128+
node
129129
});
130130
}
131131
}
132132
};
133133

134134
return {
135-
ArrowFunctionExpression: parens,
135+
ArrowFunctionExpression: parens
136136
};
137137
},
138138

@@ -141,7 +141,7 @@ export default {
141141
category: 'ECMAScript 6',
142142
description: 'require parentheses around arrow function arguments',
143143
recommended: false,
144-
url: 'https://eslint.org/docs/rules/arrow-parens',
144+
url: 'https://eslint.org/docs/rules/arrow-parens'
145145
},
146146

147147
fixable: 'code',
@@ -151,25 +151,25 @@ export default {
151151
expectedParensBlock: 'Expected parentheses around arrow function argument having a body with curly braces.',
152152

153153
unexpectedParens: 'Unexpected parentheses around single function argument.',
154-
unexpectedParensInline: 'Unexpected parentheses around single function argument having a body with no curly braces.',
154+
unexpectedParensInline: 'Unexpected parentheses around single function argument having a body with no curly braces.'
155155
},
156156

157-
type: 'layout',
157+
type: 'layout'
158158
},
159159

160160
schema: [
161161
{
162-
enum: ['always', 'as-needed'],
162+
enum: ['always', 'as-needed']
163163
},
164164
{
165165
additionalProperties: false,
166166
properties: {
167167
requireForBlockBody: {
168168
default: false,
169-
type: 'boolean',
170-
},
169+
type: 'boolean'
170+
}
171171
},
172-
type: 'object',
173-
},
174-
],
172+
type: 'object'
173+
}
174+
]
175175
};

src/rules/booleanStyle.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const schema = [
22
{
33
enum: ['bool', 'boolean'],
4-
type: 'string',
5-
},
4+
type: 'string'
5+
}
66
];
77

88
const create = (context) => {
@@ -18,7 +18,7 @@ const create = (context) => {
1818
return fixer.replaceText(node, 'boolean');
1919
},
2020
message: 'Use "boolean", not "bool"',
21-
node,
21+
node
2222
});
2323
}
2424

@@ -28,14 +28,14 @@ const create = (context) => {
2828
return fixer.replaceText(node, 'bool');
2929
},
3030
message: 'Use "bool", not "boolean"',
31-
node,
31+
node
3232
});
3333
}
34-
},
34+
}
3535
};
3636
};
3737

3838
export default {
3939
create,
40-
schema,
40+
schema
4141
};

0 commit comments

Comments
 (0)