Skip to content

Commit f0d61f4

Browse files
committed
Update looksLikeFlowFileAnnotation regex to match only @flow
The `looksLikeFlowFileAnnotation` regex was too broad and would catch jsdoc comments like `@fixable` and `@function`, causing eslint errors in projects that don't use flow (in my case). I updated the regex to only check for anything beginning with `@flo`. Is there any reason not to full on match `@flow`? I'm not familiar with how flow works. This should fix gajus#165.
1 parent f622fcd commit f0d61f4

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/rules/requireValidFileAnnotation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const defaults = {
99
};
1010

1111
const looksLikeFlowFileAnnotation = (comment) => {
12-
return /@(?:no)?f/i.test(comment);
12+
return /@(?:no)?flo/i.test(comment);
1313
};
1414

1515
const isValidAnnotationStyle = (node, style) => {

tests/rules/assertions/requireValidFileAnnotation.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ export default {
167167
}
168168
]
169169
},
170+
{
171+
code: '// @function',
172+
options: [
173+
'never',
174+
{
175+
annotationStyle: 'none'
176+
}
177+
]
178+
},
179+
{
180+
code: '// @fixable',
181+
options: [ 'error', 'never' ]
182+
},
170183
{
171184
code: '/* @flow */',
172185
options: [
@@ -178,5 +191,3 @@ export default {
178191
}
179192
]
180193
};
181-
182-

0 commit comments

Comments
 (0)