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

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"
    ]
  }

and

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

all three options throw the same validation warning on pre-commit. What am I doing wrong here?

Debug Logs

expand to view
lint-staged:bin Running `lint-staged@7.2.0` +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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 18 (2 by maintainers)

Most upvoted comments

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 lint-staged@7.1.2), which doesn’t have the issue.

What fixed it was upgrading to 7.3.0, thanks.

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

@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                       
lint-staged@8.0.0-beta.1 /Users/okonet/Projects/OSS/lint-staged
├─┬ jest@22.4.3
│ └─┬ jest-cli@22.4.3
│   ├─┬ jest-config@22.4.3
│   │ └── jest-validate@22.4.3 
│   ├─┬ jest-runtime@22.4.3
│   │ └── jest-validate@22.4.3 
│   └── jest-validate@22.4.3 
└── jest-validate@23.4.0  invalid

npm ERR! invalid: jest-validate@23.4.0 /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: