-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shared setting for pragma configuration (fixes #228)
- Loading branch information
Showing
12 changed files
with
229 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @fileoverview Utility functions for React pragma configuration | ||
* @author Yannick Croissant | ||
*/ | ||
'use strict'; | ||
|
||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/; | ||
|
||
function getFromContext(context) { | ||
var pragma = 'React'; | ||
// .eslintrc shared settings (http://eslint.org/docs/user-guide/configuring#adding-shared-settings) | ||
if (context.settings.react && context.settings.react.pragma) { | ||
pragma = context.settings.react.pragma; | ||
// Deprecated pragma option, here for backward compatibility | ||
} else if (context.options[0] && context.options[0].pragma) { | ||
pragma = context.options[0].pragma; | ||
} | ||
return pragma.split('.')[0]; | ||
} | ||
|
||
function getFromNode(node) { | ||
var matches = JSX_ANNOTATION_REGEX.exec(node.value); | ||
if (!matches) { | ||
return false; | ||
} | ||
return matches[1].split('.')[0]; | ||
} | ||
|
||
module.exports = { | ||
getFromContext: getFromContext, | ||
getFromNode: getFromNode | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.