jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.96k stars 510 forks source link

maximumLineLength allExcept functionSignatures - broken in IIFE #2032

Closed himdel closed 8 years ago

himdel commented 8 years ago

With jscs-2.7.0, maximumLineLenght.allExcept = ['functionSignatures'] does not work if such a function is wrapped in an IIFE block.

I assume that's a bug, right?

Simple case:

.jscsrc

{
  "maximumLineLength": {
    "value": 64,
    "allExcept": [
      "functionSignature"
    ]
  }
}

bug.js

function tooLongButOK_spam_spam_spam_spam_spam_spam_spam_spam_spam() {
}

(function() {
  function tooLongAndNotOK_spam_spam_spam_spam_spam_spam_spam_spam() {
  }
})();

(function() {
  "use strict";
  function tooLongAndStillNotOK_spam_spam_spam_spam_spam_spam_spam() {
  }
})();

I'd expect jscs to run on this without errors, but I get 2 errors.

markelog commented 8 years ago

It totally is! By looking at the code, it is not ideally implemented, one might say - badly implemented.

Do you wanna try to fix it?

himdel commented 8 years ago

Sure, looks like a fun xmas project :) though after a (really) quick look the day before I couldn't really make heads or tails of it..

But if I'm fixing it, do we still really want this to not apply to var foo = function(...) {?

markelog commented 8 years ago

Judging by name of the option, i'd say it would be okay to make those changes.

Happy Christmas btw!

himdel commented 8 years ago

@markelog Thanks!, Merry Christmas to you as well :)

And what do you think of #2040?, should hopefully be a bit cleaner than the current approach..