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.

"Cannot read property of 'loc' of undefined" when typing "const"

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.8.0
  • Node Version: 14.15.3
  • npm Version: 6.14.10

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using? parser: ‘@typescript-eslint/parser’,

Please show your full configuration:

Configuration
module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/vue3-essential',
    '@vue/airbnb',
    '@vue/typescript/recommended',
  ],
  parserOptions: {
    ecmaVersion: 2020,
    parser: '@typescript-eslint/parser',
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)',
      ],
      env: {
        jest: true,
      },
    },
  ],
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

When typing const, VScode is returning the following error:

ESLint: Cannot read property 'loc' of undefined Occurred while linting /xxx.ts:1. at Object.VariableDeclaration [as listener] (/xxx/node_modules/eslint/lib/rules/indent.js:1384:69)

What did you expect to happen? No error message. Apparently this was also an issue a few years ago (issue 441).

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

ESLint: Cannot read property 'loc' of undefined Occurred while linting /xxx.ts:1. at Object.VariableDeclaration [as listener] (/xxx/node_modules/eslint/lib/rules/indent.js:1384:69)

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
brandonwozcommented, Dec 25, 2020

Hi @brandonwoz, thanks for the issue!

I think this is a duplicate of #13956. Can you try with @typescript-eslint/indent instead of the core indent rule:

{
  "indent": "off",
  "@typescript-eslint/indent": ["error"]
}

This worked. Thank you!

1reaction
niceuecommented, Apr 27, 2021

The problem is still not solved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'loc' of undefined · Issue #13956 - GitHub
type const in ts file , output above error messages ... "Cannot read property of 'loc' of undefined" when typing "const" #13957.
Read more >
ESLint: Cannot read property 'loc' of undefined - Quasar forum
Hi When I typing «const» into typescript file, I take an error «ESLint: Cannot read property 'loc' of undefined» It can be fixed...
Read more >
Cannot read property 'name' of undefined Occurred while ...
Failed to compile Cannot read property 'name' of undefined Occurred while linting /Users/Reynaldo/Documents/cafemat/src/hooks/useFirebase.ts:13 ...
Read more >
Supressing ESLint LS errors - Language Server Protocol (LSP)
ESLint : Cannot read properties of undefined (reading 'loc') Occurred while linting /home/non/test/index.ts. Please see the 'ESLint' output ...
Read more >
cannot read properties of undefined (reading '_leaflet_events')
To solve the "Cannot read properties of undefined" error, make sure to insert the JS script tag at the bottom of the body....
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