Lint-staged: Validation Warning: Unknown option ( ... ) was found in the config root.

Created on 11 Aug 2018  ยท  18Comments  ยท  Source: okonet/lint-staged

Description

I have tried every way I can think of to set up the config in package.json and keep getting this warning.

I have tried:

  "lint-staged": {
    "*.{js,jsx}": ["prettier --parser flow --write","git add -f"],
    "*.css": "stylelint",
    "*.scss": "stylelint --syntax=scss"
  }
  "lint-staged": {
    "linters": {
      "*.{js,jsx}": ["prettier --parser flow --write","git add -f"],
      "*.css": "stylelint",
      "*.scss": "stylelint --syntax=scss"
    },
    "ignore": [
      "**/dist/*.min.js"
    ]
  }



md5-737442b49235034e5edab5c68a352695



  "lint-staged": {
    "linters": {
      "*.{js,jsx}": ["prettier --parser flow --write","git add -f"],
      "*.css": "stylelint",
      "*.scss": "stylelint --syntax=scss"
    }
}



md5-b8d8fff0aceb7e4770414b9676620c78



lint-staged:bin Running `[email protected]` +0ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/Users/.../Documents/_Sarah/projects/.../client/package.json`:
  lint-staged { linters:
  lint-staged    { '*.{js,jsx}': [ 'prettier --parser flow --write', 'git add -f' ],
  lint-staged      '*.css': 'stylelint',
  lint-staged      '*.scss': 'stylelint --syntax=scss' },
  lint-staged   ignore: [ '**/dist/*.min.js' ] } +8ms
  lint-staged:cfg Normalizing config +0ms
  lint-staged:cfg Validating config +1ms
โ— Validation Warning:

  Unknown option "*.{js,jsx}" with value ['prettier --parser flow --write', 'git add -f'] was found in the config root.

  You are probably trying to mix simple and advanced config formats. Adding

  "linters": {
    "*.{js,jsx}": ["prettier --parser flow --write","git add -f"]
  }

  will fix it and remove this message.

Please refer to https://github.com/okonet/lint-staged#configuration for more information...
โ— Validation Warning:

  Unknown option "*.scss" with value 'stylelint --syntax=scss' was found in the config root.

  You are probably trying to mix simple and advanced config formats. Adding

  "linters": {
    "*.scss": "stylelint --syntax=scss"
  }

  will fix it and remove this message.

Please refer to https://github.com/okonet/lint-staged#configuration for more information...
Running lint-staged with the following config:
{
  linters: {
    '*.{js,jsx}': [
      'prettier --parser flow --write',
      'git add -f'
    ],
    '*.css': 'stylelint',
    '*.scss': 'stylelint --syntax=scss'
  },
  ignore: [
    '**/dist/*.min.js'
  ],
  concurrent: true,
  chunkSize: 9007199254740991,
  globOptions: {
    matchBase: true,
    dot: true
  },
  subTaskConcurrency: 1,
  renderer: 'verbose'
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:run Resolved git directory to be `/Users/.../Documents/_Sarah/projects/.../` +1ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [ 'client/src/styles/scss/index.scss',
  lint-staged:run   'client/src/styles/css/index.css.map',
  lint-staged:run   'client/src/styles/css/index.css',
  lint-staged:run   'client/src/App.js',
  lint-staged:run   'client/.sass-cache/b7749e0937e10bf69c9e583c019129b16433a3b7/index.scssc' ] +56ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:cfg Normalizing config +64ms
  lint-staged:gen-tasks Generated task: 
  lint-staged:gen-tasks { pattern: '*.{js,jsx}',
  lint-staged:gen-tasks   commands: [ 'prettier --parser flow --write', 'git add -f' ],
  lint-staged:gen-tasks   fileList:
  lint-staged:gen-tasks    [ '/Users/.../Documents/_Sarah/projects/.../client/src/App.js' ] } +21ms
  lint-staged:gen-tasks Generated task: 
  lint-staged:gen-tasks { pattern: '*.css',
  lint-staged:gen-tasks   commands: 'stylelint',
  lint-staged:gen-tasks   fileList:
  lint-staged:gen-tasks    [ '/Users/.../Documents/_Sarah/projects/.../client/src/styles/css/index.css' ] } +1ms
  lint-staged:gen-tasks Generated task: 
  lint-staged:gen-tasks { pattern: '*.scss',
  lint-staged:gen-tasks   commands: 'stylelint --syntax=scss',
  lint-staged:gen-tasks   fileList:
  lint-staged:gen-tasks    [ '/Users/.../Documents/_Sarah/projects/.../client/src/styles/scss/index.scss' ] } +1ms
Running tasks for *.{js,jsx} [started]
Running tasks for *.css [started]
Running tasks for *.scss [started]
  lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'prettier --parser flow --write', 'git add -f' ] +0ms
  lint-staged:find-bin Resolving binary for command `prettier --parser flow --write` +0ms
  lint-staged:find-bin Binary for `prettier --parser flow --write` resolved to `/Users/.../Documents/_Sarah/projects/.../client/node_modules/.bin/prettier` +3ms
  lint-staged:task โœ”  OS: darwin; File path chunking unnecessary +0ms
  lint-staged:find-bin Resolving binary for command `git add -f` +0ms
  lint-staged:find-bin Binary for `git add -f` resolved to `/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git` +1ms
  lint-staged:task โœ”  OS: darwin; File path chunking unnecessary +1ms
  lint-staged:make-cmd-tasks Creating listr tasks for commands 'stylelint' +5ms
  lint-staged:find-bin Resolving binary for command `stylelint` +1ms
  lint-staged:find-bin Binary for `stylelint` resolved to `/Users/.../Documents/_Sarah/projects/.../client/node_modules/.bin/stylelint` +1ms
  lint-staged:task โœ”  OS: darwin; File path chunking unnecessary +2ms
  lint-staged:make-cmd-tasks Creating listr tasks for commands 'stylelint --syntax=scss' +2ms
  lint-staged:find-bin Resolving binary for command `stylelint --syntax=scss` +1ms
  lint-staged:find-bin Resolving binary for `stylelint` from cache +0ms
  lint-staged:task โœ”  OS: darwin; File path chunking unnecessary +1ms
prettier --parser flow --write [started]
stylelint [started]
stylelint --syntax=scss [started]
  lint-staged:task bin: /Users/.../Documents/_Sarah/projects/.../client/node_modules/.bin/prettier +0ms
  lint-staged:task args: [ '--parser',
  lint-staged:task   'flow',
  lint-staged:task   '--write',
  lint-staged:task   '/Users/.../Documents/_Sarah/projects/.../client/src/App.js' ] +0ms
  lint-staged:task opts: { reject: false } +0ms
  lint-staged:task bin: /Users/.../Documents/_Sarah/projects/.../client/node_modules/.bin/stylelint +13ms
  lint-staged:task args: [ '/Users/.../Documents/_Sarah/projects/.../client/src/styles/css/index.css' ] +0ms
  lint-staged:task opts: { reject: false } +1ms
  lint-staged:task bin: /Users/.../Documents/_Sarah/projects/.../client/node_modules/.bin/stylelint +4ms
  lint-staged:task args: [ '--syntax=scss',
  lint-staged:task   '/Users/.../Documents/_Sarah/projects/.../client/src/styles/scss/index.scss' ] +0ms
  lint-staged:task opts: { reject: false } +0ms
prettier --parser flow --write [completed]
git add -f [started]
  lint-staged:task bin: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git +540ms
  lint-staged:task args: [ 'add',
  lint-staged:task   '-f',
  lint-staged:task   '/Users/.../Documents/_Sarah/projects/.../client/src/App.js' ] +0ms
  lint-staged:task opts: { reject: false, cwd: '/Users/.../Documents/_Sarah/projects/.../' } +0ms
git add -f [completed]
Running tasks for *.{js,jsx} [completed]
stylelint [failed]
โ†’ 
Running tasks for *.css [failed]
โ†’ 
stylelint --syntax=scss [failed]
โ†’ 
Running tasks for *.scss [failed]
โ†’ 
โœ– "stylelint" found some errors. Please fix them and try committing again.
Error: No configuration provided for /Users/.../Documents/_Sarah/projects/.../client/src/styles/css/index.css
at module.exports (/Users/.../Documents/_Sarah/projects/.../client/node_modules/stylelint/lib/utils/configurationError.js:8:28)
at searchForConfig.then.then.config (/Users/.../Documents/_Sarah/projects/.../client/node_modules/stylelint/lib/getConfigForFile.js:49:15)
โœ– "stylelint --syntax=scss" found some errors. Please fix them and try committing again.
Error: No configuration provided for /Users/.../Documents/_Sarah/projects/.../client/src/styles/scss/index.scss
at module.exports (/Users/.../Documents/_Sarah/projects/.../client/node_modules/stylelint/lib/utils/configurationError.js:8:28)
at searchForConfig.then.then.config (/Users/.../Documents/_Sarah/projects/.../client/node_modules/stylelint/lib/getConfigForFile.js:49:15)

husky > pre-commit hook failed (add --no-verify to bypass)
...:client ...$ 

Environment

  • OS: macOS High Sierra
  • Node.js: 10.8.0
  • lint-staged: 7.2.0

Most helpful comment

Same issue, the bug seems to have appeared in 3d0ccb2. I got rid of the warning by pinning lint-staged to version 7.1.2 (yarn add -D [email protected]), which doesn't have the issue.

All 18 comments

We're seeing the same issue. May need to revert to an earlier release.

Same issue, the bug seems to have appeared in 3d0ccb2. I got rid of the warning by pinning lint-staged to version 7.1.2 (yarn add -D [email protected]), which doesn't have the issue.

I had to nuke the node_modules folder and yarn.lock to be able to reproduce the issue.

Edit: I was able to narrow it down to [email protected]. The warning does not appear for v23.4.0.

This is the PR which introduced the issue - facebook/jest#6802, working on the fix.

(Jest maintainer here) Is it a bug in jest-validate?

I'd say it should have been a breaking change..

If it correctly reports that invalid config is invalid, I don't think it should be a breaking change.

At least in our case, we relied on checking only the top level keys. The way we are usingjest-validate could be wrong. However, the config, at least in this case, wasn't the issue.

Hmm, now I'm seeing

โ— Validation Warning:

  Unknown option "recursive" with value false was found.
  This is probably a typing mistake. Fixing it will remove this message.

when using latest version from master :-/

@sudo-suhas is this something we're aware of?

@okonet Could you please share the output of npm ls jest-validate? I suspect that you have an older version of the package even though we specify the dependency version as ^23.5.0 which supports the recursive option.

@sudo-suhas interesting. Here is the output:

โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”ฌ [email protected]
โ”‚   โ”œโ”€โ”ฌ [email protected]
โ”‚   โ”‚ โ””โ”€โ”€ [email protected]  deduped
โ”‚   โ”œโ”€โ”ฌ [email protected]
โ”‚   โ”‚ โ””โ”€โ”€ [email protected]  deduped
โ”‚   โ””โ”€โ”€ [email protected]  deduped
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”€ [email protected] 
โ”œโ”€โ”ฌ [email protected] -> /Users/okonet/Projects/OSS/lint-staged invalid
โ”‚ โ””โ”€โ”€ [email protected]  invalid
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”ฌ [email protected]
    โ””โ”€โ”€ [email protected] 

npm ERR! invalid: [email protected] /Users/okonet/Projects/kleiner_perkins/crm_web_client/node_modules/lint-staged
npm ERR! invalid: [email protected] /Users/okonet/Projects/kleiner_perkins/crm_web_client/node_modules/lint-staged/node_modules/jest-validate

What I don't get is why lint-staged using the wrong version?

โ”œโ”€โ”ฌ [email protected] -> /Users/okonet/Projects/OSS/lint-staged invalid
โ”‚ โ””โ”€โ”€ [email protected]  invalid

although we're requiring the right one?

https://github.com/okonet/lint-staged/blob/4832b4c079e8d148f23d79abe09148f04fd0b3ea/package.json#L39

My guess is that there are a lot of edge cases when using package managers which are hard to reproduce and therefore hard to fix. Nuking thenode_modules folder and runningyarn will fix it. By any chance were you using npm?

Also, after rebasing did you run yarn or npm i?

@sudo-suhas I was hoping that this is why we have yarn.lock in the first place :-/

Projects/OSS/lint-staged on ๎‚  git-worflow [โ‡ก$] is ๐Ÿ“ฆ  v8.0.0-beta.1 via โฌข v10.9.0 
โ€ข100% โžœ npm ls jest-validate                       
[email protected] /Users/okonet/Projects/OSS/lint-staged
โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”ฌ [email protected]
โ”‚   โ”œโ”€โ”ฌ [email protected]
โ”‚   โ”‚ โ””โ”€โ”€ [email protected] 
โ”‚   โ”œโ”€โ”ฌ [email protected]
โ”‚   โ”‚ โ””โ”€โ”€ [email protected] 
โ”‚   โ””โ”€โ”€ [email protected] 
โ””โ”€โ”€ [email protected]  invalid

npm ERR! invalid: [email protected] /Users/okonet/Projects/OSS/lint-staged/node_modules/jest-validate

Projects/OSS/lint-staged on ๎‚  git-worflow [โ‡ก$!] is ๐Ÿ“ฆ  v8.0.0-beta.1 via โฌข v10.9.0 took 2s 
โ€ข100% โžœ yarn     
Alias tip: y
yarn install v1.9.4
[1/5] ๐Ÿ”  Validating package.json...
[2/5] ๐Ÿ”  Resolving packages...
success Already up-to-date.
โœจ  Done in 0.54s.

Nuking node_modules helps indeed. I _love_ this ecosystem! :sarcasm:

:pensive: I know what you mean.

What's the solution for this? I'm literally using the same config from the readme and getting the warning.

{
  "lint-staged": {
    "linters": {
      "*.{js,scss}": ["some command", "git add"]
    },
    "ignore": ["**/dist/*.min.js"]
  }
}
โ— Validation Warning:

  Unknown option "*.{js,scss}" with value ['some command', 'git add'] was found in the config root.

  You are probably trying to mix simple and advanced config formats. Adding

  "linters": {
    "*.{js,scss}": ["some command","git add"]
  }

  will fix it and remove this message.

Please refer to https://github.com/okonet/lint-staged#configuration for more information...
 โ†“ Running tasks for *.{js,scss} [skipped]
   โ†’ No staged files match *.{js,scss}

Try removing and reinstalling node_modules

What fixed it was upgrading to 7.3.0, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thedamon picture thedamon  ยท  3Comments

oliverzy picture oliverzy  ยท  4Comments

jasonslyvia picture jasonslyvia  ยท  3Comments

OriginUnknown picture OriginUnknown  ยท  4Comments

okonet picture okonet  ยท  5Comments