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
Warning: Object.keys called on non-object #1760
Comments
Can you share your ESLint configuration? |
Sorry guys I used a rule in a wrong way for escaping quotes. |
That's okay, can you share which rule? Even if you misconfigure, ESLint shouldn't throw an error. |
I got this error because of invalid json. I forgot to provide a value for the last line "no-mixed-spaces-and-tabs". Here is what I had in my .eslintrc. {
"env": {
"browser": true,
"node": true
},
"globals": {
"angular": true
},
"rules": {
"no-use-before-define": "nofunc",
"strict": false,
"eol-last": false,
"no-underscore-dangle": false,
"quotes": [1, 'double'],
"no-space-before-semi": [1],
"no-dangle-comma": [0],
"indent": 4,
"no-mixed-spaces-and-tabs"
}
} |
Oh very interesting! We should at least be able to tell you that's the problem when it happens. |
picking this up |
This occurred because the file shown above is valid YAML, and the value of that rule key becomes null. yaml.safeLoad(require('fs').readFileSync('bust.json','utf8'))
{ env: { browser: true, node: true },
globals: { angular: true },
rules:
{ 'no-use-before-define': 'nofunc',
strict: false,
'eol-last': false,
'no-underscore-dangle': false,
quotes: [ 1, 'double' ],
'no-space-before-semi': [ 1 ],
'no-dangle-comma': [ 0 ],
indent: 4,
'no-mixed-spaces-and-tabs': null } } |
I've pushed a PR that treats a I could probably make it error on |
I don't think we should quietly fail in this case because the error might never be found. I'd just throw an error saying "Invalid configuration for rule-name". That at least warns that there's a problem to fix. |
@michaelficarra At the moment there's no validation on rules at all, there's already #967 which dicusses why this is quite an involved change. @nzakas would the better fix to add some basic config validation on each config file, that runs before merging, and that disallows |
That's a much larger effort, which is why it hasn't been done yet (see #967). The easiest path forward here is to throw an error. |
Have pushed another draft - the logic has to live in |
Fix: don't crash when given null as rule config (fixes #1760)
Hi there.
I got the following error when i was trying to lint with the grunt-eslint plugin.
According to sindresorhus/grunt-eslint#47 it's not an issue in the plugin.
Thanks for help.
The text was updated successfully, but these errors were encountered: