0

I have a CouchDB map.js file which expects code to be defined within an unnamed function:

function(doc){
      // do something
}

Because JSCS expects the function to be named, it says:

parseError: Unexpected token (

How can I ignore this error without changing my code?

I don't want to add inline rules like // jscs:disable

Matt
  • 3,483
  • 4
  • 36
  • 46
  • So basically the linter is telling you that you can't have anonymous functions? Maybe it's time to ignore the linter – adeneo Feb 05 '16 at 18:42
  • Is that function standing alone by itself? Because that's a syntax error, which isn't a linter setting. – Mike Cluck Feb 05 '16 at 18:43
  • Well, JSCS isn't really a linter, it's just a style checker. It does have to lint to an extent but that's not it's main purpose. Sadly, this is the syntax that CouchDB uses even thought it's bad JS. – Matt Feb 05 '16 at 18:45
  • 1
    @adeneo it's not anonymous because it's not assigned to a variable or passed as a callback. – Matt Feb 05 '16 at 18:47
  • @MikeC Yes, it stands alone like that. CouchDB style. – Matt Feb 05 '16 at 18:47
  • Well, then as Mike said, it's invalid javascript, and would throw an error in any regular javascript file, so you can't reasonably expect that a ***linter*** understands that's it not javascript – adeneo Feb 05 '16 at 18:49
  • @adeneo JSHint does allow you ignore this error but I'm using JSCS. – Matt Feb 05 '16 at 21:54

0 Answers0