From b6a02403f345fc8a94a239e56c6315000ae0fc0a Mon Sep 17 00:00:00 2001 From: tillarnold Date: Wed, 29 Oct 2014 22:30:18 +0100 Subject: [PATCH] Add support for `.react.js` suffix --- tasks/jshint.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks/jshint.js b/tasks/jshint.js index a23cf7e..7607c64 100644 --- a/tasks/jshint.js +++ b/tasks/jshint.js @@ -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 {