jscs-dev / gulp-jscs Goto Github PK
View Code? Open in Web Editor NEWCheck JavaScript code style with jscs
License: MIT License
Check JavaScript code style with jscs
License: MIT License
Hi I started getting unexpected errors after updating to "gulp-jscs": "^1.1.2",
from "gulp-jscs": "^0.6.0",
Illegal space before opening round brace at app.js :
99 | '<img src="//travis-ci.org/Adaptv/adapt-strap.svg"> | current v{{ version }}</p>',
100 | link: function (scope) {
101 | $http.get('bower.json').success(function (response) {
------------------------------------------------^
102 | scope.version = response.version;
103 | });
So I configured my .jscsrc file to allow that space
{
"preset": "google",
"requireParenthesesAroundIIFE": true,
"maximumLineLength": 120,
"validateLineBreaks": "LF",
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
}
"disallowKeywords": ["with"],
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": ["string"]
}
But the error is still there. please help
No problems running the plugin to analyze my code using the following task. However when I add fix:true
, nothing changes in the files and JSCS now acts like it isn't running at all... when I remove the object passed into the JSCS plugin and remove the gulp.dest()
line, it will report code style issues.
So, it seems either passing in the fix:true
or tying to write back the fixed files causes JSCS to short circuit internally... ideas?
var $ = require('gulp-load-plugins')({lazy: true});
gulp.task('vet', function () {
log('Analyzing source with JSHint and JSCS');
return gulp
.src(config.allJs, {base: './'})
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
.pipe($.jscs({fix:true}))
.pipe(gulp.dest('./'));
});
Currently, this plugin emits an error containing the code style errors string and then gulp logs the unhandled error to the console. However, logging errors to the console does not apply the formatting correctly (at least in Windows). Logging the code style errors directly to the console instead of emitting them as an Error object would fix the issue, here's the before and after:
However, this would require either rewriting the unit tests or emitting the message twice (log directly to console, and as part of the PluginError message).
Hello,
I found a bug in gulp-jscs while writing a filter test in angluarjs. I have included the output on the console. Let me know if you need more information or if I can asset in any way.
[gulp] Error in plugin 'gulp-jscs': Operator - should not stick to preceding expression at billingFilters.spec.js :
36 | expect(currencySuffix(25145)).to.be.eq('$25.15k');
37 | expect(currencySuffix(12315100000)).to.be.eq('$12.32b');
38 | expect(currencySuffix(-1359314.12)).to.be.eq('($1.36)m');
--------------------------------------^
39 | });
I love the fact that the plugin now supports fix
- great job!
However, when I added the fix
option gulp-jscs no longer uses my own .jscsrc
file.
I would expect the following to still default to using ./.jscsrc
.
return gulp.src('app.js')
.pipe(plugins.jscs({
fix: true
}))
.pipe(gulp.dest('./src'));
But it doesn't. I have to specify
return gulp.src('app.js')
.pipe(plugins.jscs({
configPath: '.jscsrc',
fix: true
}))
.pipe(gulp.dest('./src'));
Likewise I expect
return gulp.src('app.js')
.pipe(plugins.jscs({}))
.pipe(gulp.dest('./src'));
to equal
return gulp.src('app.js')
.pipe(plugins.jscs())
.pipe(gulp.dest('./src'));
In my gulp setup the jscs task fails silently Starting 'jscs'...
when testing more than 16 files.
gulp.task('jscs', function() {
return gulp.src('./src/**/*.js')
.pipe(jscs())
});
I'd be very useful to be able to configure and use different reporters. I plan to submit a PR implementing it, but as is quite a important feature, I'd prefer to discuss it before:
$.jscs()
and $.jscs.reporter('my-reporter')
(similarly to https://github.com/spenceralger/gulp-jshint)node-jscs
reporters directly - they all write output to console.log
, so they need to be ported and modifiedcheckstyle
and xunit
reporter should combine all errors in a single single, vinyl file object. They shouldn't emit error event despite linting errors (use case: CI reports)What are your thoughts?
When working with gulp-jscs
on a Windows machine, the setup of gulp results in a file path that is too long for Windows to be able to delete. This makes it difficult to delete any parent folder containing gulp-jscs
.
Similar problem seen here and now fixed: gulpjs/gulp#630
Can anything be done to fix this?
while it has been implemented in node-jscs
We really need a force option so that gulp won't exit the task if jscs throws an error (à la grunt-jscs).
The current behavior makes it impossible to use gulp-jscs in our project which contains a lot of legacy code.
How do you feel about that?
Note: This may be related to #21.
Hey,
Thanks for making the quick update from the pr I did.
One thing though is that it still stops any kind of gulp process and throws the exception out, if you don't pass the exception to the callback. (i.e "cb(err)".)
Adding the following seemed to do the trick on my side:
this.push(file);
cb(err);
Getting this message with gulp-jscs. Possibly related to facebookarchive/esprima@2d47a78 ?
[package.json]
...
"devDependencies": {
"esprima-fb": "^13001.1001.0-dev-harmony-fb",
"gulp": "^3.8.11",
"gulp-jscs": "^1.4.0",
}
...
[gulpfile.js]
...
gulp.task('jscs', function() {
return gulp.src([
'./app/**/*.js'
])
.pipe(jscs());
});
...
https://github.com/jscs-dev/gulp-jscs/blob/master/index.js#L36
This completely ignores the error received from jscs. In my case, I had a formatting issue and the error had a message explaining where the error was. I had to edit gulp-jscs to output the error to see it, however.
Hello! In my project I have large legacy codebase, so I cannot lint whole files. I want lint only specific ranges of the file and search errors in it.
For example I have file:
function hello () {
return +'4';
}
function hello2 () {
return +'5';
}
jscs will fail on following loc: 2 and 6. But I want to ignore error in 6 loc. Is it possible to add filter function here which will take error and vinyl file object and then decide add error or not?
Right now I just got an issue because of a jscs update through gulp-jscs (about deprecated rules)
Maybe you should go to 1.x & follow a bit more the tool versionning ?
Just picking this module to ask about peerDependencies
. Webpack recommends using peerDependencies
so it's easier to use/update (from you app) the library being wrapped by the plugin. Is that frowned up on gulp plugins?
Looks like it is impossible to specify both { esnext: true }
and configPath
options in a single call. I believe the CLI options should be a separate argument from the code style options, so a new API signature could be:
jscs(configPath | lintOptions, cliOptions)
Example usage:
jscs('.jscsrc', { esnext: true })
Thoughts?
// cc @sindresorhus
JSCS have released v2.1.0, it would be nice if I could use that from gulp-jscs.
This line here throws an error.
TypeError: Object [object Object] has no method '_isExcluded'
Something has changed in the jscs
upgrade to 1.8.0
. I was able to fix this by pinning the dependency in the package.json to 1.7.3
.
Is the ideal solve to pin to this version or to fix index.js
accordingly?
When jscs is run from the command line, if a config file is not specified it's default behaviour is to look for a config file in the current directory, then its parent, grandparent, ... until it finds one.
This doesn't seem to be possible through this plugin. Because the plugin assumes that if a path is not given that settings are going to be provided directly with no config file.
Perhaps it could be changed so that if no configPath is given (and no options) that it would call loadConfigFile.load without the configPath, so that it would search up through parents. I don't think doing this would cause problems for existing gulpfiles, because currently in this scenario it would be looking in the current folder for .jscsrc; with this change it would be looking in the current folder before looking in parent folders.
Doing something like this in index.js should do the job.
if (Object.keys(options).length === 0) {
checker.configure(loadConfigFile.load(configPath));
} else {
checker.configure(options);
}
New to gulp but am getting this error:
With this gulp file:
Obviously the jscs error is expected but not the stream error.
I am using Gulp 3.9.0 and Gulp-jscs 2.0.0. When I try to runt he following Gulp task I get the error below:
gulp.task("lint-js", function () {
return gulp
.src(paths.scripts + "**/*.js")
.pipe(jscs());
});
> cmd.exe /c gulp -b "C:\WebApplication1\WebApplication1" --color --gulpfile "C:\WebApplication1\WebApplication1\Gulpfile.js" lint-js
[18:53:55] Using gulpfile C:\WebApplication1\WebApplication1\Gulpfile.js
[18:53:55] Starting 'lint-js'...
[18:53:55] 'lint-js' errored after 234 ms
[18:53:55] SyntaxError: Unable to load JSCS config file at C:\WebApplication1\WebApplication1\.jscsrc
Unexpected token
at Object.parse (native)
at Object.exports.getContent (C:\WebApplication1\WebApplication1\node_modules\gulp-jscs\node_modules\jscs\lib\cli-config.js:74:28)
at Object.exports.load (C:\WebApplication1\WebApplication1\node_modules\gulp-jscs\node_modules\jscs\lib\cli-config.js:112:21)
at module.exports (C:\WebApplication1\WebApplication1\node_modules\gulp-jscs\index.js:37:37)
at Gulp.gulp.task.sources.css.map.gulp.src.pipe.pipe.pipe.pipe.pipe.pipe.minifyCss.keepSpecialComments (C:\WebApplication1\WebApplication1\Gulpfile.js:232:15)
at module.exports (C:\WebApplication1\WebApplication1\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\WebApplication1\WebApplication1\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\WebApplication1\WebApplication1\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (C:\WebApplication1\WebApplication1\node_modules\gulp\node_modules\orchestrator\index.js:134:8)
at C:\WebApplication1\WebApplication1\node_modules\gulp\bin\gulp.js:129:20
at process._tickCallback (node.js:419:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:906:3
Process terminated with code 1.
Here is a full copy of my .jscsrc file:
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"function",
"typeof"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"requireSpaceBetweenArguments": true,
"requireMultipleVarDecl": "onevar",
"requireVarDeclFirst": true,
"requireBlocksOnNewline": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowDanglingUnderscores": true,
"requireCommaBeforeLineBreak": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeBinaryOperators": [
","
],
"requireSpacesInForStatement": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"disallowKeywords": [
"with",
"continue"
],
"validateIndentation": 4,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowKeywordsOnNewLine": [
"else"
],
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"disallowNewlineBeforeBlockStatements": true,
"disallowMultipleLineStrings": true,
"requireSpaceBeforeObjectValues": true
}
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I also asked this question on the node-jscs project page here jscs-dev/node-jscs#1786.
I get this error when I run gulp. What I'm doing wrong? Can you help me to fix it? Thanks!
C:\xampp\htdocs\test>gulp
[10:54:45] Using gulpfile C:\xampp\htdocs\test\gulpfile.js
[10:54:45] Starting 'jscs'...
[10:54:45] 'jscs' errored after 54 ms
[10:54:45] TypeError: Object.keys called on non-object
at Function.keys (native)
at NodeConfiguration.Configuration._throwNonCamelCaseErrorIfNeeded (C:\xampp
\htdocs\test\node_modules\gulp-jscs\node_modules\jscs\lib\config\configuration.j
s:461:12)
at NodeConfiguration.Configuration.load (C:\xampp\htdocs\test\node_modules\g
ulp-jscs\node_modules\jscs\lib\config\configuration.js:52:10)
at StringChecker.configure (C:\xampp\htdocs\test\node_modules\gulp-jscs\node
_modules\jscs\lib\string-checker.js:66:29)
at Checker.configure (C:\xampp\htdocs\test\node_modules\gulp-jscs\node_modul
es\jscs\lib\checker.js:26:39)
at module.exports (C:\xampp\htdocs\test\node_modules\gulp-jscs\index.js:31:1
1)
at Gulp.<anonymous> (C:\xampp\htdocs\test\gulpfile.js:46:15)
at module.exports (C:\xampp\htdocs\test\node_modules\gulp\node_modules\orche
strator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (C:\xampp\htdocs\test\node_modules\gulp\node_m
odules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (C:\xampp\htdocs\test\node_modules\gulp\node_m
odules\orchestrator\index.js:214:10)
Gulpfile.js:
'use strict';
// Include gulp
var gulp = require('gulp');
// Include Plugins
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var less = require('gulp-less');
var path = require('path');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var jscs = require('gulp-jscs');
var noop = function () {};
var stylish = require('gulp-jscs-stylish');
// Less to Css
gulp.task('less', function () {
return gulp.src('src/less/styles.less')
.pipe(less())
.pipe(gulp.dest('dist/css'));
});
// Lint Task
gulp.task('lint', function() {
return gulp.src('src/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Concatenate & Minify JS
gulp.task('scripts', function () {
return gulp.src('src/js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
// Check JS code style
gulp.task('jscs', function () {
gulp.src(['src/js/*.js'])
.pipe(jscs()) // enforce style guide
.on('error', noop) // don't stop on error
.pipe(stylish()); // log style errors
});
// Watch Files For Changes
gulp.task('watch', function () {
// local
browserSync({
proxy: "localhost/test/"
});
gulp.watch('src/js/*.js', ['jscs', 'lint', 'scripts']);
gulp.watch('src/less/*.less', ['less']);
gulp.watch(['src/less/*.less', '*.htm']).on('change', reload);
});
// Default Task
gulp.task('default', ['jscs', 'lint', 'scripts', 'watch']);
depencies in package.json:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"gulp": "^3.8.11",
"bootstrap": "^3.3.4",
"jquery": "^2.1.3"
},
"devDependencies": {
"browser-sync": "^2.3.1",
"gulp": "^3.8.11",
"gulp-concat": "^2.2.0",
"gulp-jscs": "^1.4.0",
"gulp-jscs-stylish": "^1.0.2",
"gulp-jshint": "^1.9.4",
"gulp-less": "^3.0.1",
"gulp-rename": "^1.2.0",
"uglify": "^0.1.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Any plans to update jscs to 1.7.3?
Would that just be a simple as a package.json change or would that be more involved?
As seen at https://github.com/spenceralger/gulp-jshint#results, gulp-jshint
puts some of its results on the file object so that errors can be handled later in the gulp process. I am using this feature in conjunction with gulp-notify
to create desktop notifications when linting errors are found. I'd like to be able to do the same for code style errors.
Ideally, I'd like something very similar to what jshint uses:
file.jscs.success = true
file.jscs.errors = []
file.jscs.rules = {} // shows the rules which were loaded from the config file or passed in as options
this is a terminal log:
$ gulp jscs
[gulp] Using gulpfile /Users/vstarkov/projects/box/gulpfile.js
[gulp] Starting 'jscs'...
[gulp] 'jscs' errored after 175 ms Cannot read property 'configPath' of undefined
/Users/vstarkov/projects/box/node_modules/gulp/node_modules/orchestrator/index.js:153
throw err;
^
TypeError: Cannot read property 'configPath' of undefined
at Checker.configure (/Users/vstarkov/projects/box/node_modules/gulp-jscs/node_modules/jscs/lib/checker.js:27:21)
at module.exports (/Users/vstarkov/projects/box/node_modules/gulp-jscs/index.js:13:10)
at Gulp.<anonymous> (/Users/vstarkov/projects/box/gulpfile.js:32:15)
at module.exports (/Users/vstarkov/projects/box/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:31:7)
at Gulp.Orchestrator._runTask (/Users/vstarkov/projects/box/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/Users/vstarkov/projects/box/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/Users/vstarkov/projects/box/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
at /usr/local/lib/node_modules/gulp/bin/gulp.js:77:20
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
Gulpfile.js:
var gulp = require('gulp'),
notify = require("gulp-notify"),
jscs = require('gulp-jscs');
gulp.task('jscs', function() {
gulp.src('js/main.js')
.pipe(jscs(/*'.jscsrc'*/))
.pipe(notify('JS was validated with JSCS!'));
});
gulp.task('lint', [ 'jshint', 'csslint'/*, 'jscs'*/ ]);
gulp.task('test', [ 'lint' ]);
depencies in package.json:
{
// …
"devDependencies": {
"gulp": "~3.5.6",
"gulp-csscomb": "~0.1.0",
"gulp-notify": "~1.2.1",
"gulp-jscs": "~0.4.0",
"gulp-jshint": "~1.5.0",
"jshint-stylish": "~0.1.5",
"gulp-csslint": "~0.1.3"
}
}
What I'm doing wrong?
"gulp-jscs": "^1.6.0"
TypeError: undefined is not a function
at StringChecker (node_modules\jscs\lib\string-checker.js:26:32)
at Checker (node_modules\jscs\lib\checker.js:15:19)
at Gulp.<anonymous> (gulp\jscs.js:17:10)
at module.exports (node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (node_modules\gulp\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (node_modules\gulp\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (node_modules\gulp\node_modules\orchestrator\index.js:134:8)
at AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
at process._tickCallback (node.js:355:11)
at Module.runMain [as _onTimeout] (module.js:503:11)
Running a simple gulp task:
gulp.task('testjscs', function(callback){
return gulp.src('./src/precompile/js/**/*.js')
.pipe(jscs());
});
Running grunt version of jscs task works fine.
I kinda like this option in gulp-jshint https://github.com/spalger/gulp-jshint#fail-reporter So the task doesn't have to fail if not specified. Is it standard for gulp? Do you think it's a good idea to implement it here?
I usually combine gulp-jshint and gulp-jscs in my projects but the settings look completely inconsistent (I expect them to have similar apis).
Hi there,
I used this plugin every day while I'm building internal modules... I started getting this error today and I was wondering if any of your dependencies started failing today :( Is there anything I can do to prevent that?
Thanks!
$ gulp
[13:41:51] Using gulpfile ~/dev/github-intuit/sp-quality/Gulpfile.js
[13:41:51] Starting 'build'...
[13:41:51] Starting 'clean'...
[13:41:51] Finished 'clean' after 19 ms
[13:41:51] Starting 'check'...
/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/index.js:30
if (checker._isExcluded(file.path)) {
^
TypeError: Object [object Object] has no method '_isExcluded'
at DestroyableTransform.through.obj.emit.gutil.PluginError.showStack [as _transform] (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/index.js:30:15)
at DestroyableTransform.Transform._read (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
at doWrite (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
at writeOrBuffer (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
at write (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jshint/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jshint/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (/home/mdesales/dev/github-intuit/sp-quality/node_modules/gulp-jshint/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
at DestroyableTransform.emit (events.js:92:17)
Moved from #81 (comment)
I don't really see the point, but @dcneiner can try to convince any of the other maintainers.
For data that comes over an API I can not use camelcase in the names, so I'd like to use something like:
function (data) {
/* jshint ignore:start */
return data.verbose_name + ': ' + data.name;
/* jshint ignore:end */
};
or even better:
function (data) {
/* jshint camelcase:false */
return data.verbose_name + ': ' + data.name;
};
I'm not sure if I'm doing something wrong, but when I feed an array of sources to gulp.src that includes a wildcard that recursively results in more than sixteen files, jscs only checks the first 16 files it encounters. An example src : ./assets/js/**/*.js
Though if I run jscs from the command line with that source, it hits all the files.
Using the following syntax:
gulp.task('jscs', function(){
return gulp.src('src/*.js')
.pipe(jscs({
esnext: true
}))
});
I don't get any output. Running jscs --esnext
on the CLI reports properly, and using the option with the gulp-jscs-custom
module works though.
This would allow people to use esprima-fb and have JSCS run on their jsx files.
Expected indentation of 4 characters at main.js :
251 |
252 | return self;
253 | };
------------^
254 |
255 | new App(doc, FileAPI, new Dom()).init();
Expected indentation of 4 characters at main.js :
253 | };
254 |
255 | new App(doc, FileAPI, new Dom()).init();
------------^
256 |
257 |})(this, this.document);
at Transform._flush (/Users/vstarkov/Documents/Яндекс.Диск/projects/FBK/blackbox/node_modules/gulp-jscs/index.js:39:23)
at Transform.<anonymous> (/Users/vstarkov/Documents/Яндекс.Диск/projects/FBK/blackbox/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:135:12)
at Transform.g (events.js:175:14)
at Transform.EventEmitter.emit (events.js:92:17)
at finishMaybe (/Users/vstarkov/Documents/Яндекс.Диск/projects/FBK/blackbox/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:372:12)
at endWritable (/Users/vstarkov/Documents/Яндекс.Диск/projects/FBK/blackbox/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:379:3)
at Transform.Writable.end (/Users/vstarkov/Documents/Яндекс.Диск/projects/FBK/blackbox/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:357:5)
at Stream.onend (stream.js:79:10)
at Stream.EventEmitter.emit (events.js:117:20)
at end (/Users/vstarkov/Documents/Яндекс.Диск/projects/FBK/blackbox/node_modules/gulp/node_modules/vinyl-fs/node_modules/map-stream/index.js:116:39)
I was just trying to use gulp-jscs plugin for the first time, but was unable to get it running. I have a very simple environment with gulp, where everything works fine until I add gulp-jscs to the pipeline.
This is how the crash looks like (from the terminal):
[gulp] Using file /Users/michal/Dropbox/www/withlove-admin/gulpfile.js
[gulp] Working directory changed to /Users/michal/Dropbox/www/withlove-admin
[gulp] Running 'watch'...
[gulp] Finished 'watch' in 10 ms
File /Users/michal/Dropbox/www/withlove-admin/dev/scripts/main.js was changed, running tasks...
gulp.run() has been deprecated. Use task dependencies or gulp.watch task triggering instead.
[gulp] Running 'jscodetyle'...
[gulp] Running 'scripts'...
[gulp] Errored 'jscodetyle' in 67 ms Operator + should not stick to preceding expression at test.js :
4 |a = 0;
5 |b = 1
6 |x = a+1;
-------------^
7 |
Operator + should not stick to following expression at test.js :
4 |a = 0;
5 |b = 1
6 |x = a+1;
-------------^
7 |
/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp/node_modules/orchestrator/index.js:153
throw err;
^
[gulp] Error in plugin 'gulp-jscs': Operator + should not stick to preceding expression at test.js :
4 |a = 0;
5 |b = 1
6 |x = a+1;
-------------^
7 |
Operator + should not stick to following expression at test.js :
4 |a = 0;
5 |b = 1
6 |x = a+1;
-------------^
7 |
at Transform._flush (/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp-jscs/index.js:35:23)
at Transform.<anonymous> (/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:130:12)
at Transform.g (events.js:175:14)
at Transform.EventEmitter.emit (events.js:92:17)
at finishMaybe (/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:356:12)
at endWritable (/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:363:3)
at Transform.Writable.end (/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:341:5)
at Stream.onend (stream.js:79:10)
at Stream.EventEmitter.emit (events.js:117:20)
at end (/Users/michal/Dropbox/www/withlove-admin/node_modules/gulp/node_modules/vinyl-fs/node_modules/map-stream/index.js:116:39)
This is how I pipe the plugin:
gulp.task('jscodetyle', function() {
return gulp.src('dev/scripts/**/*.js')
.pipe(jscs());
});
Then I just call it from gulp.watch
when any .js file changes. This is how the whole gulpfile.js looks like:
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
jscs = require('gulp-jscs'),
server = lr();
gulp.task('styles', function() {
return gulp.src('dev/styles/main.scss')
.pipe(sass({ style: 'expanded' }))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('dist/assets/css'))
.pipe(livereload(server))
.pipe(notify({ message: 'Styles task complete' }));
});
gulp.task('scripts', function() {
return gulp.src('dev/scripts/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('dist/assets/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/js'))
.pipe(livereload(server))
.pipe(notify({ message: 'Scripts task complete' }));
});
gulp.task('jscodetyle', function() {
return gulp.src('dev/scripts/**/*.js')
.pipe(jscs());
});
gulp.task('images', function() {
return gulp.src('dev/images/**/*')
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('dist/assets/img'))
.pipe(livereload(server))
.pipe(notify({ message: 'Images task complete' }));
});
gulp.task('html', function() {
return gulp.src('dev/*.html')
.pipe(gulp.dest('dist/'))
.pipe(livereload(server))
.pipe(notify({ message: 'HTML task complete' }));
});
gulp.task('clean', function() {
return gulp.src(['dist/assets/css', 'dist/assets/js', 'dist/assets/img'], {read: false})
.pipe(clean());
});
gulp.task('default', ['clean'], function() {
gulp.run('jscodetyle', 'styles', 'scripts', 'images');
});
gulp.task('watch', function() {
// Watch .html files
gulp.watch('dev/*.html', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
gulp.run('html');
});
// Watch .scss files
gulp.watch('dev/styles/**/*.scss', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
gulp.run('styles');
});
// Watch .js files
gulp.watch('dev/scripts/**/*.js', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
gulp.run('jscodetyle');
gulp.run('scripts');
});
// Watch image files
gulp.watch('dev/images/**/*', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
gulp.run('images');
});
});
I'm trying to run jscs using gulp-jscs without color in the error output because despite my terminal accepting the gulp coloring just fine, jscs output is a mess of \[32
style ANSI strings instead of actual color. I know the jscs CLI can be told to use --no-color but for the life of me I can't figure out how to make the gulp-jscs task do the same. There's no mention in the docs anywhere, and no amount of Google or Stackoverflow is getting me any closer to an answer =)
It would be nice to be able to pass your own jscs instance as an option, instead of using this module's jscs dep.
Otherwise, if there are updates to jscs you want and you're using gulp-jscs, you have to wait for an update or make PR.
I am getting the following error message:
[14:52:05] 'jscs' errored after 2.04 s
[14:52:05] Error in plugin 'gulp-jscs'
Message:
Cannot read property 'value' of undefined
You should propagate any exceptions thrown by jscs
or at the very least print their stack-trace.
it's out now :-)
Task
gulp.task('scripts', function() { gulp.src(path.join(app.bower.dir, 'bootstrap/js/*.js')) .pipe(tasks.jscs()) .pipe(gulp.dest(path.join(app.scripts.dst, 'bootstrap'))); });
Error
[gulp] Using file /home/baka/test/Gulpfile.js [gulp] Working directory changed to /home/baka/test [gulp] Running 'scripts'... [gulp] Finished 'scripts' in 65 ms events.js:72 throw er; // Unhandled 'error' event ^ Error: gulp-jscs: Operator , should stick to preceding expression at carousel.js : 41 | Carousel.DEFAULTS = { 42 | interval: 5000 43 | , pause: 'hover' ----------^ 44 | , wrap: true 45 | } Operator , should stick to preceding expression at carousel.js : 42 | interval: 5000 43 | , pause: 'hover' 44 | , wrap: true ----------^ 45 | } 46 | at /home/baka/test/node_modules/gulp-jscs/index.js:21:14 at wrappedMapper (/home/baka/test/node_modules/gulp-jscs/node_modules/event-stream/node_modules/map-stream/index.js:76:19) at Stream.stream.write (/home/baka/test/node_modules/gulp-jscs/node_modules/event-stream/node_modules/map-stream/index.js:88:21) at Stream.ondata (stream.js:51:26) at Stream.EventEmitter.emit (events.js:95:17) at queueData (/home/baka/test/node_modules/gulp/node_modules/event-stream/node_modules/map-stream/index.js:38:21) at queueData (/home/baka/test/node_modules/gulp/node_modules/event-stream/node_modules/map-stream/index.js:51:14) at queueData (/home/baka/test/node_modules/gulp/node_modules/event-stream/node_modules/map-stream/index.js:51:14) at next (/home/baka/test/node_modules/gulp/node_modules/event-stream/node_modules/map-stream/index.js:68:5) at /home/baka/test/node_modules/gulp/node_modules/event-stream/node_modules/map-stream/index.js:77:7
Environment
baka@gentoo ~/test $ npm list --depth=0 [email protected] /home/baka/test ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected] baka@gentoo ~/test $ bower list bower check-new Checking for new versions of the project dependencies.. test#0.0.1 /home/baka/test ├─┬ bootstrap#3.0.3 │ └── jquery#2.0.3 ├─┬ jquery.cookie#1.4.0 │ └── jquery#2.0.3 └── videojs#4.3.0
This might be an issue for gulp since it's related to through2, but I ran into it with the latest gulp-jscs. The 'end' event is never triggered if jscs is last and there are more than 16 files. It sounds related to this rvagg/through2#18.
I am not sure if this is expected or not, but I get the following when I run gulp-jscs
and there are errors in the JS. There is an exception that wraps the jscs error list. This seems to be caused by the PluginError
that is thrown. My expectation was that there would not be any exception thrown and instead just the jscs errors logged. Also, I noticed the first jscs error is on the same line as the gutil.log statement.
stream.js:94
throw er; // Unhandled stream error in pipe.
^
[gulp] Error in plugin 'gulp-jscs': Operator , should stick to preceding expression at module.js :
21 | 'li.common.four-oh-four',
22 | 'li.common.to-top'
23 | ,'li.common.button'
------------^
at Transform._flush (/Users/adam.ayres/lia/LDKn/node_modules/gulp-jscs/index.js:35:23)
at Transform.<anonymous> (/Users/adam.ayres/lia/LDKn/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:130:12)
at Transform.g (events.js:175:14)
at Transform.EventEmitter.emit (events.js:92:17)
at finishMaybe (/Users/adam.ayres/lia/LDKn/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:354:12)
at endWritable (/Users/adam.ayres/lia/LDKn/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:361:3)
at Transform.Writable.end (/Users/adam.ayres/lia/LDKn/node_modules/gulp-jscs/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:339:5)
at Stream.onend (stream.js:79:10)
at Stream.EventEmitter.emit (events.js:117:20)
at end (/Users/adam.ayres/lia/LDKn/node_modules/gulp/node_modules/map-stream/index.js:108:39)
at queueData (/Users/adam.ayres/lia/LDKn/node_modules/gulp/node_modules/map-stream/index.js:57:17)
at next (/Users/adam.ayres/lia/LDKn/node_modules/gulp/node_modules/map-stream/index.js:68:5)
at /Users/adam.ayres/lia/LDKn/node_modules/gulp/node_modules/map-stream/index.js:77:7
at /Users/adam.ayres/lia/LDKn/node_modules/gulp/lib/createInputStream/bufferFile.js:7:5
at fs.js:266:14
at /Users/adam.ayres/lia/LDKn/node_modules/gulp-karma/node_modules/karma/node_modules/graceful-fs/graceful-fs.js:103:5
at /Users/adam.ayres/lia/LDKn/node_modules/gulp/node_modules/graceful-fs/graceful-fs.js:103:5
at Object.oncomplete (fs.js:107:15)
Hi all,
just curious about supporting of new JSCS version which supports more new ES2015/ES6 features, like destructuring.
For example,
function someFn(a, b, {c = 1, d = 2} = {}) {
// some code
}
Current version of JSCS (1.12) which gulp-jscs depends on, throws a ParseError because Esprima parser doesn't support syntax like this.
Maybe there is some workaround on this?
Thanks so much
There are several jscs options that worked with gulp-jscs 5.0 and now don't work. I have combed the jscs changelog and they should still work. I have a simple setup that highlights the issue:
https://gist.github.com/dstroot/41553de0eb13522e0d4d
If anyone has advice please let me know.
I know there's been a few of these requests in the past, but I think 1.12.0 is significant enough to merit bumping the lower bounds of the gulp-jscs
package.
Ideally, this would be to eventually support allowing options like auto-fixing through, considering thats a whopper of a feature to be missing through gulp.
Hi,
With the latest version (1.2.0), I've got this error.
I use gulp-jscs with these settings:
.pipe(jscs({
preset: 'crockford',
validateIndentation: 2,
requireMultipleVarDecl: null,
disallowDanglingUnderscores: null
}));
Here, the full traceback:
[12:43:38] TypeError: Cannot delete property 'esnext' of #<Object>
at module.exports (/home/alexis/workspace/mimosa/node_modules/gulp-jscs/index.js:15:10)
at Gulp.gulp.task.gulp.src.pipe.templateCache.module (/home/alexis/workspace/mimosa/gulpfile.js:328:11)
at module.exports (/home/alexis/workspace/mimosa/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
at Gulp.Orchestrator._runTask (/home/alexis/workspace/mimosa/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
at Gulp.Orchestrator._runStep (/home/alexis/workspace/mimosa/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
at Gulp.Orchestrator.start (/home/alexis/workspace/mimosa/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
at /usr/lib/node_modules/gulp/bin/gulp.js:121:20
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
at node.js:902:3
I have no problem with the 1.1.2.
Thanks.
Full disclosure: I'm not sure this is a gulp-jscs problem. This is a crosspost from StackOverflow.
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var watch = require('gulp-watch');
var paths = {
scripts: ['./js/*.js']
}
var jscsRunner = jscs({
disallowMixedSpacesAndTabs: true // etc
});
var jshintRunner = jshint({
browser: true // etc
});
// this outputs messages from jshint no problem
gulp.task('jshint', function() {
return gulp.src(paths.scripts)
.pipe(jshintRunner)
.pipe(jshint.reporter('default'));
});
// this outputs messages from jscs no problem
gulp.task('jscs', function() {
return gulp.src(paths.scripts)
.pipe(jscsRunner);
});
// this only outputs messages from jshint
gulp.task('watch', function() {
return watch(paths.scripts)
.pipe(jscsRunner)
.pipe(jshintRunner)
.pipe(jshint.reporter('default'));
});
The problem is that when I run gulp watch
I get no output from jscs, but when I run gulp jscs
it works.
So it seems to be connected to gulp-watch. Either that or I'm missing something really stupid here, in which case I'd be glad if you could help me out.
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.