Xo: Unable to turn off cap-new rule

Created on 16 Mar 2016  路  5Comments  路  Source: xojs/xo

With the code

import Sentence from './Sentence'
const sentenceComponent = Sentence(sentenceSources)

where sentence is a function

And this is my package.json

 "xo": {
    "esnext": true,
    "semicolon": false,
    "space": 2,
    "envs": [
      "browser",
      "node"
    ],
    "rules": {
      "new-cap": 0,
      "comma-dangle": [2, "only-multiline"]
    }
  }

I always get this error for 'Sentance' in VS Code. I am exiting and restarting code every time I change package.json

A function with a name starting with an uppercase letter should only be used as a constructor. (babel/new-cap)
(alias) Sentence(sources: any): {
    DOM: any;
}
import Sentence
I have tried variations of the rule like.
'new-cap': [0, {newIsCap: true, capIsNew: true}],
'new-cap': [2, {newIsCap: false, capIsNew: false}],
question

All 5 comments

Try setting "babel/new-cap" rule, instead of "new-cap".

"rules": {
  "babel/new-cap": 0
}

result!

Thanks. I did wonder what the babel prefix was for but could not find such rules in the ESLinit web site.

Reopening so I don't forget to better document this. It's a side-effect of using babel-eslint.

As a comment I occasionally got 2 errors at same time, one with babel/ and one without.

Also in VC Code I often had to switch back to a file several timer before the errors showed. Might be a bug or might be me.

babel-eslint is removed in master. Will do a release in the next few days.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SamVerschueren picture SamVerschueren  路  4Comments

Igor-Scekic picture Igor-Scekic  路  3Comments

EdJoPaTo picture EdJoPaTo  路  3Comments

DavidAnson picture DavidAnson  路  8Comments

niftylettuce picture niftylettuce  路  6Comments