jscs-dev / grunt-jscs Goto Github PK
View Code? Open in Web Editor NEWGrunt task for JSCS
Home Page: https://npmjs.org/package/grunt-jscs
License: MIT License
Grunt task for JSCS
Home Page: https://npmjs.org/package/grunt-jscs
License: MIT License
When building using grunt-jscs
I get Warning: Unsupported rules: requireSpaceBeforeKeywords Use --force to continue.
Upgrading to a newer version of grunt-jscs
fixes the problem but the underlying issue should get fixed. That is: don't silently skip jscs on an unknown rule, break the build instead so developers will notice the problem.
Not totally sure about them, since they might be out of scope of this plugin, but, why not?
To reduce confusion for npm users, you should run the following in terminal:
npm deprecate grunt-jscs-checker "This is deprecated. Please use 'grunt-jscs'."
Referring to dbb347e
Sure --esnext
is buggy, but I believe this plugin should not just silently ignore this option when the user requests to use it.
As of Grunt 0.4.2, grunt.util._
is being deprecated.
We should begin using lodash directly, as a recommendation from the Grunt team.
Could you loosen this up a bit? Perhaps switch to caret notation so we can get updates more fluidly from the main project?
Other tasks like grunt-contrib-jshint output something like this when everything is fine:
>> 36 files lint free.
This is a nice sanity check to see how many files actually got validated, and doesn't have any overhead (for the reader) compared to >> No code style errors found.
.
So here an equivalent would be nice:
>> 36 files without style errors
Right now this is even commented here.
Self descriptive title.
When setting 'force' flag on task i expect to force only that task execution, however it changes grunt 'force' option and make force globally. For example if you want only a report with code style mistakes and then build project, 'force' option makes grunt process always to exit with success, so there is no way to identify if build is failed from exit code. This is very important for automated builds and CI.
After checking history found out that "local" task forcing was implemented before, however it was removed with changes in 9969a2c.
Maybe i should ask why this task forcing made global?
Just like reporter
option in grunt-contrib-jshint or formatter
in eslint-grunt.
I think it would better to choose eslint-grunt
path - as value, it would take either name of one of jscs
default reporters or path to the custom one. If not defined, it would work as of now. As happy consequence it could relieve us from junit
reporter code.
I talk with @mdevils about implementing it on jscs
level but unfortunately, it's not possible due to jscs
architecture.
Plugin Config:
grunt.config('jscs', {
src: [
'**/*.js',
'!<%= yeoman.app %>/bower_components/**',
'!<%= yeoman.app %>/scripts/vendor/**',
'!<%= yeoman.dist %>/**',
'!<%= yeoman.server %>/**',
'!node_modules/**'
],
options: {
config: '.jscs.json'
}
});
Running the build
alias tasks cause force
to be undefined
grunt.registerTask('build', [
'jscs',
'concurrent:dist'
]);
Running "concurrent:dist" (concurrent) task
[ 'copy:styles',
'--_modernizr.defaults=[object Object]',
'--_modernizr.private=[object Object]' ]
[ 'imagemin',
'--_modernizr.defaults=[object Object]',
'--_modernizr.private=[object Object]' ]
[ 'svgmin',
'--_modernizr.defaults=[object Object]',
'--_modernizr.private=[object Object]' ]
[ 'htmlmin',
'--_modernizr.defaults=[object Object]',
'--_modernizr.private=[object Object]' ]
Hi!
We're currently using grunt-jscs-checker in one of our projects, and recently, there was an update to node-jscs in 1.4.4 that caused everything to break (jscs-dev/node-jscs#376).
Since your version dependancy was set to ~1.4.3 (which really means 1.4.X), it was causing us to download the broken 1.4.4. I would suggest being explicit about which version to match rather then using ~.
Let me know if you think this is a good change :)
By default, config
option uses .jscs.json
value, which might be implicitly merged with inline options.
It might be better to change its default value to null
, like jshintrc
option for grunt-contrib-jshint, so user could define this option explicitly then otherwise.
But that would be a breaking change :-(
So you could define it through the grunt task?
Less spacy and very similar to jquery.
Ref #62.
Create docs about our own coding style.
Maybe add it into the CONTRIBUTING.md
file.
Would be nice to have a default configuration file defined.
Running "jscs:files" (jscs) task
Fatal error: Neither config file nor grunt options were defined
After doing npm install grunt-jscs --save-dev
and modifying Gruntfile.js
with grunt.loadNpmTasks("grunt-jscs")
and task section I get the following error when running grunt jscs
:
Loading "jscs.js" tasks...ERROR
>> Error: Cannot find module 'vow'
If I then run npm install vow
I get the following error:
Loading "jscs.js" tasks...ERROR
>> Error: Cannot find module 'jscs/lib/checker'
Relates to #37.
Just as a reminder for me.
I would like to ignore a certain sub-folder or files inside certain folders. How do I do that? Generally all files which are defined in my jshint
should be taken BUT a certain sub-folder
should be ignored
. Is there a ignores option
? I would like to ignore all js files
in my folder: <%= arcwork.source %>/js/3rd/**/*.js
. This is already defined in my jshint
task.
This is what I have so far:
// ************************************************************************
// jshint
// ************************************************************************
jshint: {
options: {
jshintrc: '.jshintrc',
ignores: ['<%= arcwork.source %>/js/3rd/**/*.js']
},
all: {
src: [ 'Gruntfile.js',
'<%= arcwork.source %>/js/**/*.js',
'<%= arcwork.test %>/**/*.js',
],
},
},
// ************************************************************************
// jscs
// ************************************************************************
jscs: {
src: "<%= jshint.all %>",
options: {
config: "../.jscsrc"
// Is there a option to ignore folders???
}
}
The package that previously existed as "grunt-jscs" was unpublished. Since the "-checker" postfix makes this module harder to discover, it might be worth renaming this module to "grunt-jscs" and publishing new versions under that name.
reporterOutput
option has no effect if no value is given to reporter
option.
Right now, despite JSCS being able to parse JSON files with comments (and in the future, YAML files), grunt-jscs-checker can only parse JSON files.
Rather than using grunt.file.readJSON
, use jscs/lib/cli-config
to load the config.
I was wondering why grunt-newer wasn't working with this- it looks like that plugin only works with certain ways of declaring file sources.
It might be worth your time to update the readme to include an example with this sytax:
all: {
files: [
{ src: '*.js' },
{ src: 'tasks/**/*.js' }
]
}
It could probably be solved on the grunt-newer side of things, but it might save someone a little bit of headache since most of the other grunt modules work with newer out of the box.
If you'd like, I can make a PR. Thanks!
In my config I use disallowMultipleVarDecl: true
but I run the task it reports that my code is not matching rule on code like that:
var foo = 'bar',
bar = 'baz';
for (var i = 0, l = 42; i < l; i++) {
// doing stuff
}
Is it me not understanding the meaning of disallowMultipleVarDecl
keyword?
But I really think it's inverted with requireMultipleVarDecl
, as when I set the last one to true
it passes.
We use jscs as watc-task and have a few additional rules (for example we include jscs-rules).
At first time jscs works just fine and find errors. Next time we change files we see "Warning: Unsupported rules: requireFunctionsContent".
I assume it happens because task are starting every time but additionalRules was deleted and new rules doesn't registered yet.
$ npm install grunt-jscs-checker --save-dev
npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants grunt@~0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@~0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@~0.4.0
npm ERR! peerinvalid Peer [email protected] wants [email protected]
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! code EPEERINVALID
npm ERR! not ok code 0
From the blog post on peer dependencies:
The best way to determine what your peer dependency requirements should be is to actually follow semver. Assume that only changes in the host package's major version will break your plugin. Thus, if you've worked with every 1.x version of the host package, use "~1.0" or "1.x" to express this. If you depend on features introduced in 1.5.2, use ">= 1.5.2 < 2".
So, package.json line 37 should be something like "grunt": "~0.4.0"
or "grunt": ">= 0.4.2 < 0.5"
EDIT: (It's worth pointing out that upgrading the packages reported above resolves this problem, at least at the time of writing. Still, it's nice to future-proof.)
We found a few regressions. We'll let you know as soon as it's out.
I hate it, i never hate something so strongly in my life!
@gustavohenke can we switch to more normal release process, like https://github.com/jscs-dev/node-jscs/blob/master/MAINTAIN.md#user-content-publishing-a-new-version?
jscs
globally - npm uninstall -g jscs
jscs
to package.json
- "jscs": "1.4.1"
npm install
jscs .
Error: Cannot find module '../../presets/jquery.json'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/christian/Projects/calcentral/node_modules/jscs/lib/options/preset.js:2:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Installing it globally (with -g
) works correctly.
I was using external .jscsrc file.
By setting this, I am also trying to exclude some files by setting it either in the jscsrc / in the grunt options, like so:
jscs: {
dev: {
options: {
config: '.jscsrc',
excludeFiles: ['*.config.js']
},
files: {
src: [**/*.js]
}
}
}
It didn't work at all no matter where i put the excludeFiles option.
Is this expected? or i miss something?
Hi,
As explained in https://medium.com/@addyosmani/auto-formatting-javascript-code-style-fe0f98a923b8#1e26 , could you support jscs myfile.js -x
which will reformat code according the .jscsrc config
Thx !
I am getting this when trying to run with a [email protected] compatible config.
Warning: Unsupported rules: disallowOperatorBeforeLineBreak, disallowPaddingNewlinesBeforeKeywords, requirePaddingNewlinesBeforeKeywords, requireSpaceBetweenArguments, requireSpacesInForStatement Use --force to continue.
Shouldn't new (read unsupported) rules be ignored rather than explode?
This is probably a combination of a bug in grunt-jscs-checker, a bug in upstream jscs and a bug in upstream grunt.
When a file being checked contains a syntax error (e.g. unexpected end on input), the following is the result of running grunt:
[0] $ grunt build jscs qunit
Running "build:all" (build) task
>> File "dist/oojs.js" created.
Running "jscs:src" (jscs) task
[0] $
Two issues:
I've narrowed it down to the following code in /tasks/jscs.js
:
files.map( jscs.checkFile, jscs ).forEach(function( promise ) {
if ( !promise ) {
update();
return;
}
promise.then(function( errors ) {
...
update();
});
});
I tried adding an error handling (second argument of Promise.then), and that caught it. Alternatively, changing it from Promise.then to Promise.done makes Grunt handle by catching the uncaught exception there.
Adding the error handler (by passing to grunt.fail.warn
), and calling grunt with --stack
provides the following:
Error: Syntax error at src/foo.js: Line 14: Unexpected end of input
at StringChecker.checkString (node_modules/grunt-jscs-checker/node_modules/jscs/lib/string-checker.js:156:19)
at node_modules/grunt-jscs-checker/node_modules/jscs/lib/checker.js:58:26
at Array.0 (node_modules/grunt-jscs-checker/node_modules/jscs/node_modules/vow/lib/vow.js:194:56)
at callFns (node_modules/grunt-jscs-checker/node_modules/jscs/node_modules/vow/lib/vow.js:452:35)
at process._tickCallback (node.js:415:13)
The reason this exception is actually able to strangle grunt is not in jscs. The jscs lib actually catches this exception internally and then passes it as data argument when it rejects the vow/promise.
However vow/promise will throw a global exception (using nextTick) if no error handler is given and the code uses .done
instead of .then
. When .then
is used (as the code currently does), it is silently ignored.
I'm not sure why then, why the current code kills grunt. But either way, we should handle the error.
If I set my config file to '.jscsrc', and I additionally list excludeFiles, then the paths for those exclude files will be relative to the .jscsrc file in my current directory. If I list the config file as 'config/.jscsrc', then all the excludeFile paths will be relative to config/, because that is where the .jscsrc file is. I would assume that the options would be copied from the .jscsrc file, but everything would continue to operate from my cwd. If I am wrong here, could a feature be added to allow me to set the grunt-task to run against my cwd instead of the directory of the config file?
Thanks!
If you have this code:
var x = (function(){
// do stuff
})();
The rule "requireSpaceBeforeBlockStatements": true kicks in which conflicts with
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
}
Is this expected behaviour? It would be useful to get feedback on usage of rules that are conflicting.
I found the spacing rules around function declaration/expressions named/anonymous a bit confusing.
Thanks
How do I customize esprime?
Missed in docs.
I want to set the --verbose
flag, but adding that to options
throws an error "Unsupported rule: verbose", since all options are simply handled as rules.
It's out now!
@markelog @mikesherov @Krinkle
Anyone has anything else to request for the next release?
Now that it's released!
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.