question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Unexpected top-level property "$schema"

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 10.15.0
  • npm Version: 6.4.1

What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser

Please show your full configuration:

{
  "$schema": "http://json.schemastore.org/eslintrc",
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint"
  ],
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "rules": {
    "@typescript-eslint/restrict-plus-operands": "error"
  }
}

What did you expect to happen?

The $schema field is the standard way to tell editors where to find schema for a JSON file. Without this field, IntelliSense won’t be available when people edit the .eslint.json config file.

The $schema field is documented in the JSON Schema spec: https://json-schema.org/latest/json-schema-core.html#rfc.section.7

What actually happened? Please include the actual, raw output from ESLint.

It appears that when ESLint validates the .eslint.json file, it rejects the $schema field. It prints this error:

Error: ESLint configuration in .eslintrc.json is invalid:
        - Unexpected top-level property "$schema".

    at validateConfigSchema (D:\GitRepos\eslint-test\node_modules\eslint\lib\shared\config-validator.js:286:15)
    at ConfigArrayFactory._normalizeConfigData (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\config-array-factory.js:469:9)
    at ConfigArrayFactory._loadConfigDataInDirectory (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\config-array-factory.js:445:33)
    at ConfigArrayFactory.loadInDirectory (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\config-array-factory.js:401:18)
    at CascadingConfigArrayFactory._loadConfigInAncestors (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:304:46)
    at CascadingConfigArrayFactory.getConfigArrayForFile (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:249:18)
    at FileEnumerator._iterateFilesRecursive (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\file-enumerator.js:408:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (D:\GitRepos\eslint-test\node_modules\eslint\lib\cli-engine\file-enumerator.js:254:49)
    at iterateFiles.next (<anonymous>)

Are you willing to submit a pull request to fix this bug?

Yes. The simplest fix is for ESLint to delete the $schema field after it loads the file.

If people agree that we should fix this, I’m happy to create the PR.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Aug 27, 2019

I don’t think we would specifically support $schema, but I wonder if we could have a whitelist of extra keys we will allow but ignore, and maybe we could add that key to such a list.

I would be okay with evaluating a proposal along those lines in a new issue.

1reaction
octogonzcommented, Jul 21, 2019

It’s a pretty cool feature! You get tab completion when typing:

json-intellisense

…and error-underlining if you type it wrong: json-error

…and documentation tooltips when you mouse over a setting: json-tooltip

The editor obtains this information by downloading the schema (e.g. http://json.schemastore.org/eslintrc) that it discovers from the $schema field.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESlint ERROR: Unexpected top-level property "installedESLint"
I have the same issue, since upgrading eslint package from 3.13.1 to 4.19.1 and eslint-config-airbnb from 14.0.0 to 16.1.0. Did you figure ...
Read more >
JSON Schema Serializer and Deserializer
Configure the deserializer with a value for type.property that indicates the name of a top-level property on the JSON schema that specifies the...
Read more >
OpenAPI Specification - Version 3.0.3 - Swagger
(OAS 2.0 documents contain a top-level version field named swagger and value "2.0" .) ... by a format property follow the type definition...
Read more >
Handling Validation Errors - python-jsonschema
When an invalid instance is encountered, a ValidationError will be raised or returned, depending on which method or function is used. exception jsonschema....
Read more >
eslint/eslint - Gitter
its coming like " - Unexpected top-level property "configs"." hornta. @hornta ... 474:1 error Replace ↹↹ with ···· prettier/prettier
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found