Skip to content

Commit

Permalink
Add support for .react.js suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
tillarnold committed Oct 29, 2014
1 parent 41ce9c7 commit b6a0240
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tasks/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ var docblock = require('jstransform/src/docblock');
var origLint = jshintcli.__get__("lint");

var jsxSuffix = ".jsx";
var reactJsSuffix = '.react.js';

//override the lint function to also transform the jsx code
jshintcli.__set__("lint", function myLint(code, results, config, data, file) {
var isJsxFile = file.indexOf(jsxSuffix, file.length - jsxSuffix.length) !== -1;
var isReactJsFile = file.indexOf(reactJsSuffix, file.length - reactJsSuffix.length) !== -1;
var hasSuffix = isJsxFile || isReactJsFile;

//added check for having /** @jsx React.DOM */ comment
var hasDocblock = docblock.parseAsObject(docblock.extract(code)).jsx;
if (isJsxFile && !hasDocblock) {
if (hasSuffix && !hasDocblock) {
code = '/** @jsx React.DOM */' + code;
}
if (isJsxFile || hasDocblock) {
if (hasSuffix || hasDocblock) {
var compiled;

try {
Expand Down

0 comments on commit b6a0240

Please sign in to comment.