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: duplicated mapping key" while reading YAML eslintrc file

See original GitHub issue

We wanted to switch from an older version (1.10.3) to the current one (2.3.0). Our eslintrc is in Yaml and worked fine with the old ESLint version. When using it with 2.3.0 we get an error while ESLint tries to read the eslintrc:

YAMLException: Cannot read config file: /home/tom/code/foo/.eslintrc
Error: duplicated mapping key at line 52, column 3:
      no-func-assign:
      ^

The key is not duplicated in the file and there are no other config files in parent folders. When I converted the Yaml to a JSON file and used that, all worked fine.

Debug output of eslint --debug app/assets/javascripts/ spec/javascripts/:

  eslint:cli Running on files +0ms
  eslint:ignored-paths Looking for ignore file in /home/tom/code/foo +50ms
  eslint:ignored-paths Loaded ignore file /home/tom/code/foo/.eslintignore +1ms
  eslint:ignored-paths Adding /home/tom/code/foo/.eslintignore +0ms
  eslint:cli-engine Processing /home/tom/code/foo/app/assets/javascripts/application/admin/dashboard.js +11ms
  eslint:cli-engine Linting /home/tom/code/foo/app/assets/javascripts/application/admin/dashboard.js +1ms
  eslint:config Constructing config for /home/tom/code/foo/app/assets/javascripts/application/admin/dashboard.js +0ms
  eslint:config Using .eslintrc and package.json files +0ms
  eslint:config Loading /home/tom/code/foo/.eslintrc +1ms
  eslint:config-file Loading config file: /home/tom/code/foo/.eslintrc +1ms
  eslint:config-file Error reading YAML file: /home/tom/code/foo/.eslintrc +27ms
Cannot read config file: /home/tom/code/foo/.eslintrc
Error: duplicated mapping key at line 52, column 3:
      no-func-assign:
      ^
YAMLException: Cannot read config file: /home/tom/code/foo/.eslintrc
Error: duplicated mapping key at line 52, column 3:
      no-func-assign:
      ^
    at generateError (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:162:10)
    at throwError (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:168:9)
    at storeMappingPair (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:305:7)
    at readBlockMapping (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1065:9)
    at composeNode (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1326:12)
    at readBlockMapping (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1056:11)
    at composeNode (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1326:12)
    at readDocument (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1488:3)
    at loadDocuments (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1544:5)
    at load (/usr/lib/node_modules/eslint/node_modules/js-yaml/lib/js-yaml/loader.js:1561:19)

ESLint version v2.3.0

full configuration

rules:
  indent:
    - 2
    - 2
  no-mixed-spaces-and-tabs:
    - 2
  quotes:
    - 2
    - "single"
    - "avoid-escape"
  linebreak-style:
    - 2
    - unix
  no-extra-semi:
    - 2
  no-redeclare:
    - 2
  no-unused-vars:
    - 2
  comma-dangle:
    - 2
  no-cond-assign:
    - 2
    - "always"
  no-console:
    - 2
  no-constant-condition:
    - 2
  no-control-regex:
    - 2
  no-debugger:
    - 2
  no-dupe-args:
    - 2
  no-dupe-keys:
    - 2
  no-duplicate-case:
    - 2
  no-empty-character-class:
    - 2
  no-empty:
    - 2
  no-ex-assign:
    - 2
  no-extra-boolean-cast:
    - 2
  no-extra-parens:
    - 2
    - "functions"
  no-extra-semi:
    - 2
  no-func-assign:
    - 2
  no-inner-declarations:
    - 2
  no-invalid-regexp:
    - 2
  no-irregular-whitespace:
    - 2
  no-negated-in-lhs:
    - 2
  no-obj-calls:
    - 2
  no-regex-spaces:
    - 2
  no-sparse-arrays:
    - 2
  no-unexpected-multiline:
    - 2
  no-unreachable:
    - 2
  use-isnan:
    - 2
  valid-jsdoc:
    - 2
  valid-typeof:
    - 2
  accessor-pairs:
    - 2
  block-scoped-var:
    - 2

env:
  browser: true
  jquery: true
# extends: 'eslint:recommended'

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mysticateacommented, Mar 15, 2016

Thank you for this issue.

That error message seems to be confused. Actually, no-extra-semi is duplicated.

0reactions
nzakascommented, Mar 22, 2016

There nothing we can do about this. It’s up to js-yaml to fix it, and if and when they do, it’ll get included in ESLint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: duplicated mapping key at line 45, column 30 ...
It will print out all the information about config files that are being loaded and merged by ESLint. That should point you in...
Read more >
Duplicate mapping key in configuration.yaml
Hi, This is my code: mqtt: binary_sensor: name: 'deur_gang' state_topic: “tele/Bridge1/RESULT” value_template: '{{value_json.RfReceived.
Read more >
yamllint - Read the Docs
When linting a document with yamllint, a series of rules (such as line-length, trailing-spaces, etc.) are checked against. A configuration file ...
Read more >
Hi, i have been having issues with my template. trying to track ...
Debug: internal, implementation, error; YAMLException: duplicated mapping key at line 5, column 1: limit: 4; ^; at generateError ...
Read more >
Ubuntu Manpage: yamllint -
yamllint - A linter for YAML files. yamllint does not only check for syntax ... 5:4 error duplication of key "id-00042" in mapping...
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