Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation Warning: Unknown option ( ... ) was found in the config root. #482

Closed
rifkegribenes opened this issue Aug 11, 2018 · 18 comments
Closed

Comments

@rifkegribenes
Copy link

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
@gvincentlh
Copy link

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

@jmerle
Copy link

jmerle commented Aug 11, 2018

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.

@sudo-suhas
Copy link
Collaborator

sudo-suhas commented Aug 11, 2018

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 jest-validate@23.5.0. The warning does not appear for v23.4.0.

@sudo-suhas
Copy link
Collaborator

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

@SimenB
Copy link
Contributor

SimenB commented Aug 13, 2018

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

@sudo-suhas
Copy link
Collaborator

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

@SimenB
Copy link
Contributor

SimenB commented Aug 13, 2018

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

@sudo-suhas
Copy link
Collaborator

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.

@okonet
Copy link
Collaborator

okonet commented Sep 7, 2018

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 okonet reopened this Sep 7, 2018
@sudo-suhas
Copy link
Collaborator

@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.

@okonet
Copy link
Collaborator

okonet commented Sep 10, 2018

@sudo-suhas interesting. Here is the output:

├─┬ jest@23.5.0
│ └─┬ jest-cli@23.5.0
│   ├─┬ jest-config@23.5.0
│   │ └── jest-validate@23.5.0  deduped
│   ├─┬ jest-runtime@23.5.0
│   │ └── jest-validate@23.5.0  deduped
│   └── jest-validate@23.5.0  deduped
├─┬ jest-junit@5.1.0
│ └── jest-validate@23.5.0 
├─┬ lint-staged@8.0.0-beta.1 -> /Users/okonet/Projects/OSS/lint-staged invalid
│ └── jest-validate@23.4.0  invalid
└─┬ ts-jest@22.4.0
  └─┬ jest-config@22.4.4
    └── jest-validate@22.4.4 

npm ERR! invalid: lint-staged@8.0.0-beta.1 /Users/okonet/Projects/kleiner_perkins/crm_web_client/node_modules/lint-staged
npm ERR! invalid: jest-validate@23.4.0 /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?

├─┬ lint-staged@8.0.0-beta.1 -> /Users/okonet/Projects/OSS/lint-staged invalid
│ └── jest-validate@23.4.0  invalid

although we're requiring the right one?

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

@sudo-suhas
Copy link
Collaborator

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?

@sudo-suhas
Copy link
Collaborator

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

@okonet
Copy link
Collaborator

okonet commented Sep 10, 2018

@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:

@okonet okonet closed this as completed Sep 10, 2018
@sudo-suhas
Copy link
Collaborator

😔 I know what you mean.

@Abdisalan
Copy link

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}

@okonet
Copy link
Collaborator

okonet commented Oct 19, 2018

Try removing and reinstalling node_modules

@Abdisalan
Copy link

What fixed it was upgrading to 7.3.0, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants