schorfES / grunt-lintspaces

A Grunt task for checking spaces in files.
https://npmjs.com/package/grunt-lintspaces
MIT License
31 stars 9 forks source link

Does not showCodes / showTypes beyond first file. #26

Closed glenpike closed 9 years ago

glenpike commented 9 years ago

With the following config:

all: {
        src: [
            'Gruntfile.js',
            'grunt/**/*.js',
            'build-config/**/*.js',
            'webapp/**/*.js',
            '!webapp/vendor/**/*.js',
            'tests/**/*.js'
        ],

        options: {
            ignores: [
                'js-comments'
            ],
            showTypes: true,
            showCodes: true,
            editorconfig: '.editorconfig'
        }
    }

I get a number of errors, but the errors are only shown for the first file:

☓ webapp/module1/views/add.js
  L3: (warning) Expected an indentation at 4 instead of at 2. [INDENTATION_SPACES_AMOUNT]
  L4: (warning) Expected an indentation at 4 instead of at 2. [INDENTATION_SPACES_AMOUNT]
  L5: (warning) Expected an indentation at 4 instead of at 2. [INDENTATION_SPACES_AMOUNT]
  L33: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L34: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L36: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L37: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L38: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L40: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L41: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L42: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
  L43: (warning) Expected an indentation at 24 instead of at 22. [INDENTATION_SPACES_AMOUNT]
  L44: (warning) Expected an indentation at 20 instead of at 18. [INDENTATION_SPACES_AMOUNT]
☓ webapp/module1/views/edit.js
☓ webapp/module1/views/table.js
☓ webapp/module2/view.js
☓ webapp/module2/views/editing-app.js
☓ webapp/module3/app.js
☓ webapp/module3/views/filterCollectionView.js
...
schorfES commented 9 years ago

Mmmmh, what happens when you fix the issues in the first file?

glenpike commented 9 years ago

It moves onto the next one in the list, i.e. only errors are shown for

☓ webapp/module1/views/edit.js

Running lintspaces directly works fine, e.g. shows errors for all the files.

schorfES commented 9 years ago

Have you any other task installed which compresses the output? Can you post a copy of your package.json here?

glenpike commented 9 years ago

Hi,

Here is our package JSON:

{
  "name": "app-prototype",
  "version": "0.0.0",
  "description": "app demo",
  "main": "webapp/main.js",
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "dependencies": {
    "tmp": "~0.0.23",
    "grunt-cli": "~0.1.13",
    "grunt": "~0.4.5"
  },
  "devDependencies": {
    "chai": "~1.9.1",
    "glob": "~4.3.2",
    "grunt": "^0.4.5",
    "grunt-auto-install": "^0.2.3",
    "grunt-config": "~0.2.2",
    "grunt-contrib-clean": "~0.6.0",
    "grunt-contrib-copy": "^0.7.0",
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-rename": "0.0.3",
    "grunt-contrib-requirejs": "~0.4.4",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-focus": "~0.1.1",
    "grunt-karma": "~0.9.0",
    "grunt-lintspaces": "^0.6.0",
    "grunt-pattern-replace": "~1.0.1",
    "grunt-po2json": "git+https://github.com/rockykitamura/grunt-po2json.git",
    "grunt-replace": "~0.8.0",
    "grunt-sass": "~0.17.0",
    "grunt-string-replace": "~1.0.0",
    "grunt-xgettext": "^0.3.5",
    "http-server": "^0.7.4",
    "i18next": "^1.7.9",
    "i18next-conv": "^0.1.4",
    "intern": "^2.1.1",
    "karma": "~0.12.23",
    "karma-chai": "~0.1.0",
    "karma-chrome-launcher": "~0.1.4",
    "karma-coverage": "~0.2.6",
    "karma-html2js-preprocessor": "~0.1.0",
    "karma-junit-reporter": "~0.2.2",
    "karma-mocha": "~0.1.9",
    "karma-phantomjs-launcher": "~0.1.4",
    "karma-requirejs": "~0.2.2",
    "load-grunt-tasks": "~2.0.0",
    "lodash": "~3.0.0",
    "mocha": "~1.21.4",
    "requirejs": "~2.1.15",
    "underscore": "^1.7.0"
  },
  "scripts": {
    "test": "test"
  },
  "repository": {
    "type": "git",
    "url": "local/git/url"
  },
  "author": "",
  "license": "ISC"
}

Here is a stripped version of our Gruntfile.js showing the task we are trying to run (We've split the grunt tasks into individual modules - the lintspaces one is shown above in the first comment):

module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

    grunt.registerTask('lintspaces-test', ['lintspaces']);

    var config = {
        pkg: grunt.file.readJSON('package.json'),
        env: process.env
    };

    function loadConfig(path) {
        var glob = require('glob');
        var object = {};
        var key;
        glob.sync('*', {
            cwd: path
        }).forEach(function(option) {
            key = option.replace(/\.js$/, '');
            object[key] = require(path + option);
        });

        return object;
    }

    grunt.util._.extend(config, loadConfig('./grunt/tasks/options/'));
    //console.log('con9fig ', config)
    grunt.initConfig(config);
};
schorfES commented 9 years ago

Mmmmh, i've expected to see any other dependencies which may influence the output of grunt but I didn't see anything conspicuous in your package.json.

So you say: "Running lintspaces directly works fine, e.g. shows errors for all the files.", which means when you call grunt lintspaces it works as expected but calling grunt lintspaces-test it won't?

schorfES commented 9 years ago

Ahhhh, I think I found the issue in the code (see https://github.com/schorfES/grunt-lintspaces/blob/master/tasks/lintspaces.js#L55). If there are already warnings reported, the reportMessages()function won't be called again...

I will fix this!

glenpike commented 9 years ago

Cool, thanks :+1:

schorfES commented 9 years ago

published via npm @ version 0.6.1

glenpike commented 9 years ago

Works great thanks :+1: