Skip to content

Commit

Permalink
feat: update looksLikeFlowFileAnnotation regex to match only @flow (#…
Browse files Browse the repository at this point in the history
…233)

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 #165.
  • Loading branch information
Robdel12 authored and gajus committed May 30, 2017
1 parent f622fcd commit 42328cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/rules/requireValidFileAnnotation.js
Expand Up @@ -9,7 +9,7 @@ const defaults = {
};

const looksLikeFlowFileAnnotation = (comment) => {
return /@(?:no)?f/i.test(comment);
return /@(?:no)?flo/i.test(comment);
};

const isValidAnnotationStyle = (node, style) => {
Expand Down
15 changes: 13 additions & 2 deletions tests/rules/assertions/requireValidFileAnnotation.js
Expand Up @@ -167,6 +167,19 @@ export default {
}
]
},
{
code: '// @function',
options: [
'never',
{
annotationStyle: 'none'
}
]
},
{
code: '// @fixable',
options: [ 'error', 'never' ]
},
{
code: '/* @flow */',
options: [
Expand All @@ -178,5 +191,3 @@ export default {
}
]
};


0 comments on commit 42328cd

Please sign in to comment.