Giter Site home page Giter Site logo

grunt-jscs's People

Contributors

ahmednuaman avatar hzoo avatar icecreamyou avatar jacksonrayhamilton avatar jasonkarns avatar joeybaker avatar leobalter avatar markelog avatar mikesherov avatar nschonni avatar paladox avatar pdehaan avatar solenoid avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grunt-jscs's Issues

Fail build on unsupported rules

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.

Deprecate grunt-jscs-checker

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'."

Update the node-jscs version

Could you loosen this up a bit? Perhaps switch to caret notation so we can get updates more fluidly from the main project?

Output the number of valid files

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

Tests

Self descriptive title.

Change 'force' behaviour

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?

Add reporter option

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.

--force=undefined

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'
  ]);

Using this plugin:

Running concurrent without this plugin

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]' ]

Tighten up dependancy versions

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 :)

Default value of the config option

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 :-(

Verbose flag

So you could define it through the grunt task?

Code Style

Create docs about our own coding style.
Maybe add it into the CONTRIBUTING.md file.

Default configuration 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

Dependency problems

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'

How to ignore files and folders?

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???
      }
    }

bump jscs dependency version

It seems that when I install this plugin it installs version 1.6.2 of jscs, but the current version of jscs is at 1.7.3.

And because of that disallowSpacesInCallExpression, requirePaddingNewLinesInObjects and requireFunctionDeclarations are not recognised.

Rename to grunt-jscs

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.

Grunt/grunt-jscs-checker adds too much overhead

I've added jscs to AngularJS build and I see that with grunt the style check takes ~30% longer than without grunt (on a large project like ours that's 3+ seconds).

screen shot 2014-01-30 at 10 31 09 am

Can something be done about this?

Have the `config` option be loaded using JSCS's loader

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.

Readme file config could be updated

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!

disallowMultipleVarDecl inversion

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.

additionalRules doesn't work properly with grunt-contrib-watch

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.

Relax package.json grunt peerDependencies

$ 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.)

Installing jscs locally doesn't work.

To reproduce

  1. Remove jscs globally - npm uninstall -g jscs
  2. Add jscs to package.json - "jscs": "1.4.1"
  3. Run npm install
  4. Run jscs .

Output

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.

excludeFiles are not working

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?

Out of sync with node-jscs

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?

Syntax error found by jscs lib is eaten by promise, then silently passes by ending with exit code 0

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:

  • No where did it report an error.
  • Grunt completely stopped, it doesn't report the task completed, it doesn't report the task failed or timed out, it doesn't start the next task. And the process ends, as if all tests passed, with exit code 0.

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.

setting config options changes directory for exclude files

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!

Clarification over block expression and anonymous function spaces

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

Expose CLI options

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.