tillarnold / grunt-jsxhint Goto Github PK
View Code? Open in Web Editor NEWLike grunt-contrib-jshint but compatible with react's jsx
License: MIT License
Like grunt-contrib-jshint but compatible with react's jsx
License: MIT License
React 0.12.0 was just released and no longer requires the /** @jsx React.DOM */ pragma at the top of the file. The React components in their example apps in the flux repo (https://github.com/facebook/flux/tree/master/examples/flux-chat/js/components) use .react.js file extensions instead of .jsx ones. However, if I remove the pragma, files with .react.js extension are no longer treated as JSX files since the code looks for one of .jsx or the pragma. Could you allow .react.js files by default to be treated as JSX files? Or, alternately, allow the user to configure the grunt task to specify the file suffix they're using?
I'm not understanding how to use this grunt task. It doesn't seem to be processing my .jsx files.
I have both grunt-jsxhint and grunt-contrib-jshint installed.
My GruntFile.js
module.exports = function (grunt) {
grunt.initConfig({
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: {
src: [
'js/**/*.js',
'js/**/*.jsx'
]
}
}
});
require('load-grunt-tasks')(grunt, {
pattern: ["grunt-*"]
});
};
However, when I run "grunt jshint" only the .js files are validated, and there is no option to run "grunt jsxhint" and no option to specify that the 'jshint' task should use 'grunt-jsxhint'.
This is a project to lint code, so it's own source should be linted as well.
Hi,
Great grunt task! Would it be possible sometime to add the option to pass options to react-tools? I need to set harmony:true :)
update rewire and check if everything works.
It is not parsing ES6 properly in my config:
My relevant code. Inside initConfig
:
jshint: {
target: 'assets/*.jsx',
options: {
ignores: [],
additionalSuffixes: ['.js']
}
},
Then at the end, after initConfig({ ... })
:
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-jsxhint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-notify');
grunt.registerTask('default', ['jshint', 'shell', 'sass', 'notify:build']);
I've tried tweaking and changing few things but still the same error
I'm guessing everything is run through the transformer as it is.
I have thousands of files that aren't jsx yet. Plugging in grunt-jsxhint as a drop in replacement considerably slows down my linting.
Any way to be able to tell the linter which files should be transformed and which should pass through untouched?
As mentioned in #13 we should add a option for custom file suffixes.
My grunt file is super simple:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-jsxhint');
/* Project configuration */
grunt.initConfig({
options: {
jshintrc: '.jshintrc',
ignores: [],
additionalSuffixes: ['.js', '.ios.js']
},
jshint: {
all: ['./app/index.ios.js']
}
});
/* Test Tasks */
grunt.registerTask('test', ['jshint']);
};
When I do a grunt test
, I get the following errors.
But when I installed npm install -g jsxhint
I can do a test and see the proper result
It seems like react-tools
is a real dependency, not a devDependency.
Depending on a specific version of react-tools, while the user might be using a different one can lead to problems. I've run into similar issues for every precompiler out there.
The best solution is to do a try/catch for requiring react-tools and throw an error if it is not installed, hopefully with a helpful error message on how to fix the problem
If you have a case where say you have your linter looking for single quotes and after your .jsx file is processed and through processing gets strings surrounded by single quotes the linter will fail. But really you don't care if the transformed code passes linting. Just the original code. Is there a way to just ignore the transformed code while linting?
Hi,
I've saw the recent update which stops the support of JSX syntax inside ".js",
I still want to use ".js" because it works better with Browserify.
If we look at plugins like reactify
: https://github.com/andreypopp/reactify they do the support like this:
reactify
transform activates for files with either.jsx
extension or/** @jsx React.DOM */
pragma as a first line for any.js
file.
I'm going to continue to use 0.0.2 of this plugin waiting for a fix.
Best regards,
gre
Hi,
I want to use your plugin, but i faced a problem, that there are no ability to use babel transformation instead of react tools.
Are you plan to provide this ability?
JSXTransformer produces warning when babel-core transform comes across spread operator in object destructuring assignment (https://babeljs.io/docs/plugins/transform-object-rest-spread/).
Since it is a stage-2 feature, a presets array needs to be passed to the transform function options.
Maybe allow the passing of an extra preset options from the jshint Gruntfile (similar to additionalSuffxes)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.