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

ESLint: Cannot read property 'loc' of undefined. #792

Closed
deviprsd opened this issue Aug 2, 2019 · 5 comments · Fixed by reedsy/eslint-config-reedsy#7
Closed

ESLint: Cannot read property 'loc' of undefined. #792

deviprsd opened this issue Aug 2, 2019 · 5 comments · Fixed by reedsy/eslint-config-reedsy#7
Labels
awaiting response Issues waiting for a reply from the OP or another party package: parser Issues related to @typescript-eslint/parser

Comments

@deviprsd
Copy link

deviprsd commented Aug 2, 2019

This bug still exists, #441

import { CalendarioOptions, DEFAULTS } from './lib/options'
import { TimeZoneError } from './lib/errors'
import { CalendarioEvents, processEvents, ProcessedCalendarioEvents } from './lib/events'
import { Settings, Info, Zone, DateTime } from 'luxon';

export default function calendario (events?: CalendarioEvents, options: CalendarioOptions = {}, today?: Date): void {
    let zone: Zone

    Settings.throwOnInvalid = true

    options = {...DEFAULTS, ...options}
    const resolvedOpts = DateTime.fromObject({ locale: options.locale, numberingSystem: options.numberingSystem }).resolvedLocaleOpts()
    
    const // <- error happened here
    if(!(zone = Info.normalizeZone(options.timeZone)).isValid) {
        throw new TimeZoneError(`Invalid timezone ${options.timeZone}`)
    }
    
    Settings.defaultZoneName = zone.name
    Settings.defaultLocale = resolvedOpts.locale
    Settings.defaultNumberingSystem = resolvedOpts.numberingSystem
    Settings.defaultOutputCalendar = 'gregory'

    const _today: DateTime = today ? DateTime.fromJSDate(today) : DateTime.local()
    const _events: ProcessedCalendarioEvents = processEvents({...events}, options)
}

export { INFO } from './lib/options'

Code I have been working on, was restructing and changing a let to const

2019-08-02T08:32:43.801Z eslint:cli CLI args: [ './src/index.ts', '--debug' ]
2019-08-02T08:32:43.804Z eslint:cli Running on files
2019-08-02T08:32:43.807Z eslint:ignored-paths baseDir = "/home/deviprsd/Projects/CalendarioFX/Calendario"
2019-08-02T08:32:43.808Z eslint:ignored-paths addPatternRelativeToCwd:
  original = "/node_modules/*"
  cooked   = "/node_modules/*"
2019-08-02T08:32:43.808Z eslint:ignored-paths addPatternRelativeToCwd:
  original = "/bower_components/*"
  cooked   = "/bower_components/*"
2019-08-02T08:32:43.808Z eslint:ignored-paths addPatternRelativeToCwd:
  original = ".*"
  cooked   = ".*"
2019-08-02T08:32:43.808Z eslint:ignored-paths addPatternRelativeToCwd:
  original = "!../"
  cooked   = "!../"
2019-08-02T08:32:43.808Z eslint:ignored-paths Looking for ignore file in /home/deviprsd/Projects/CalendarioFX/Calendario
2019-08-02T08:32:43.809Z eslint:ignored-paths Loaded ignore file /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintignore
2019-08-02T08:32:43.809Z eslint:ignored-paths Adding /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintignore
2019-08-02T08:32:43.810Z eslint:ignored-paths addPatternRelativeToIgnoreFile:
  original = "/index.*js"
  cooked   = "/index.*js"
2019-08-02T08:32:43.810Z eslint:ignored-paths addPatternRelativeToIgnoreFile:
  original = "/index.*js"
  cooked   = "/index.*js"
2019-08-02T08:32:43.810Z eslint:ignored-paths baseDir = "/home/deviprsd/Projects/CalendarioFX/Calendario"
2019-08-02T08:32:43.810Z eslint:ignored-paths addPatternRelativeToCwd:
  original = "/node_modules/*"
  cooked   = "/node_modules/*"
2019-08-02T08:32:43.810Z eslint:ignored-paths addPatternRelativeToCwd:
  original = "/bower_components/*"
  cooked   = "/bower_components/*"
2019-08-02T08:32:43.811Z eslint:ignored-paths Looking for ignore file in /home/deviprsd/Projects/CalendarioFX/Calendario
2019-08-02T08:32:43.811Z eslint:ignored-paths Loaded ignore file /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintignore
2019-08-02T08:32:43.811Z eslint:ignored-paths Adding /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintignore
2019-08-02T08:32:43.811Z eslint:ignored-paths addPatternRelativeToIgnoreFile:
  original = "/index.*js"
  cooked   = "/index.*js"
2019-08-02T08:32:43.811Z eslint:ignored-paths addPatternRelativeToIgnoreFile:
  original = "/index.*js"
  cooked   = "/index.*js"
2019-08-02T08:32:43.812Z eslint:file-enumerator Start to iterate files: [ './src/index.ts' ]
2019-08-02T08:32:43.813Z eslint:file-enumerator File: /home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts
2019-08-02T08:32:43.813Z eslint:cascading-config-array-factory Load config files for /home/deviprsd/Projects/CalendarioFX/Calendario/src.
2019-08-02T08:32:43.813Z eslint:cascading-config-array-factory No cache found: /home/deviprsd/Projects/CalendarioFX/Calendario/src.
2019-08-02T08:32:43.813Z eslint:config-array-factory Config file not found on /home/deviprsd/Projects/CalendarioFX/Calendario/src
2019-08-02T08:32:43.813Z eslint:cascading-config-array-factory No cache found: /home/deviprsd/Projects/CalendarioFX/Calendario.
2019-08-02T08:32:43.814Z eslint:config-array-factory Loading JS config file: /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:43.814Z eslint:config-array-factory Config file found: /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:43.827Z eslint:config-array-factory Loading {extends:"eslint:recommended"} relative to /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:43.827Z eslint:config-array-factory Loading JS config file: /usr/lib/node_modules/eslint/conf/eslint-recommended.js
2019-08-02T08:32:43.827Z eslint:config-array-factory Loading {extends:"plugin:@typescript-eslint/eslint-recommended"} relative to /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:43.828Z eslint:config-array-factory Loading plugin "@typescript-eslint" from /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:43.829Z eslint:config-array-factory Loaded: @typescript-eslint/eslint-plugin@1.13.0 (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js)
2019-08-02T08:32:44.075Z eslint:config-array-factory Loading {extends:"plugin:@typescript-eslint/recommended"} relative to /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:44.076Z eslint:config-array-factory Loading plugin "@typescript-eslint" from /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:44.076Z eslint:config-array-factory Loaded: @typescript-eslint/eslint-plugin@1.13.0 (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js)
2019-08-02T08:32:44.076Z eslint:config-array-factory Loading {extends:"./configs/base.json"} relative to /home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js
2019-08-02T08:32:44.077Z eslint:config-array-factory package.json was not found: Cannot find module './configs/base.json/package.json'
Require stack:
- /home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js
2019-08-02T08:32:44.077Z eslint:config-array-factory Loaded: ./configs/base.json (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.json)
2019-08-02T08:32:44.077Z eslint:config-array-factory Loading JSON config file: /home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.json
2019-08-02T08:32:44.078Z eslint:config-array-factory Loading parser "@typescript-eslint/parser" from /home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.json
2019-08-02T08:32:44.079Z eslint:config-array-factory Loaded: @typescript-eslint/parser@1.13.0 (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/parser/dist/parser.js)
2019-08-02T08:32:44.093Z eslint:config-array-factory Loading plugin "@typescript-eslint" from /home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.json
2019-08-02T08:32:44.093Z eslint:config-array-factory Loaded: @typescript-eslint/eslint-plugin@1.13.0 (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js)
2019-08-02T08:32:44.093Z eslint:config-array-factory Loading parser "@typescript-eslint/parser" from /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:44.094Z eslint:config-array-factory Loaded: @typescript-eslint/parser@1.13.0 (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/parser/dist/parser.js)
2019-08-02T08:32:44.095Z eslint:config-array-factory Loading plugin "@typescript-eslint" from /home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js
2019-08-02T08:32:44.095Z eslint:config-array-factory Loaded: @typescript-eslint/eslint-plugin@1.13.0 (/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js)
2019-08-02T08:32:44.095Z eslint:cascading-config-array-factory No cache found: /home/deviprsd/Projects/CalendarioFX.
2019-08-02T08:32:44.095Z eslint:config-array-factory Config file not found on /home/deviprsd/Projects/CalendarioFX
2019-08-02T08:32:44.095Z eslint:cascading-config-array-factory No cache found: /home/deviprsd/Projects.
2019-08-02T08:32:44.095Z eslint:config-array-factory Config file not found on /home/deviprsd/Projects
2019-08-02T08:32:44.095Z eslint:cascading-config-array-factory No cache found: /home/deviprsd.
2019-08-02T08:32:44.095Z eslint:cascading-config-array-factory Stop traversing because of considered root.
2019-08-02T08:32:44.097Z eslint:rules Loading rule 'constructor-super' (remaining=265)
2019-08-02T08:32:44.098Z eslint:rules Loading rule 'for-direction' (remaining=264)
2019-08-02T08:32:44.098Z eslint:rules Loading rule 'getter-return' (remaining=263)
2019-08-02T08:32:44.103Z eslint:rules Loading rule 'no-async-promise-executor' (remaining=262)
2019-08-02T08:32:44.103Z eslint:rules Loading rule 'no-case-declarations' (remaining=261)
2019-08-02T08:32:44.104Z eslint:rules Loading rule 'no-class-assign' (remaining=260)
2019-08-02T08:32:44.104Z eslint:rules Loading rule 'no-compare-neg-zero' (remaining=259)
2019-08-02T08:32:44.104Z eslint:rules Loading rule 'no-cond-assign' (remaining=258)
2019-08-02T08:32:44.105Z eslint:rules Loading rule 'no-const-assign' (remaining=257)
2019-08-02T08:32:44.106Z eslint:rules Loading rule 'no-constant-condition' (remaining=256)
2019-08-02T08:32:44.107Z eslint:rules Loading rule 'no-control-regex' (remaining=255)
2019-08-02T08:32:44.109Z eslint:rules Loading rule 'no-debugger' (remaining=254)
2019-08-02T08:32:44.109Z eslint:rules Loading rule 'no-delete-var' (remaining=253)
2019-08-02T08:32:44.109Z eslint:rules Loading rule 'no-dupe-args' (remaining=252)
2019-08-02T08:32:44.110Z eslint:rules Loading rule 'no-dupe-class-members' (remaining=251)
2019-08-02T08:32:44.110Z eslint:rules Loading rule 'no-dupe-keys' (remaining=250)
2019-08-02T08:32:44.110Z eslint:rules Loading rule 'no-duplicate-case' (remaining=249)
2019-08-02T08:32:44.111Z eslint:rules Loading rule 'no-empty' (remaining=248)
2019-08-02T08:32:44.112Z eslint:rules Loading rule 'no-empty-character-class' (remaining=247)
2019-08-02T08:32:44.112Z eslint:rules Loading rule 'no-empty-pattern' (remaining=246)
2019-08-02T08:32:44.112Z eslint:rules Loading rule 'no-ex-assign' (remaining=245)
2019-08-02T08:32:44.113Z eslint:rules Loading rule 'no-extra-boolean-cast' (remaining=244)
2019-08-02T08:32:44.113Z eslint:rules Loading rule 'no-extra-semi' (remaining=243)
2019-08-02T08:32:44.114Z eslint:rules Loading rule 'no-fallthrough' (remaining=242)
2019-08-02T08:32:44.115Z eslint:rules Loading rule 'no-func-assign' (remaining=241)
2019-08-02T08:32:44.115Z eslint:rules Loading rule 'no-global-assign' (remaining=240)
2019-08-02T08:32:44.117Z eslint:rules Loading rule 'no-inner-declarations' (remaining=239)
2019-08-02T08:32:44.118Z eslint:rules Loading rule 'no-invalid-regexp' (remaining=238)
2019-08-02T08:32:44.119Z eslint:rules Loading rule 'no-irregular-whitespace' (remaining=237)
2019-08-02T08:32:44.121Z eslint:rules Loading rule 'no-misleading-character-class' (remaining=236)
2019-08-02T08:32:44.122Z eslint:rules Loading rule 'no-mixed-spaces-and-tabs' (remaining=235)
2019-08-02T08:32:44.123Z eslint:rules Loading rule 'no-new-symbol' (remaining=234)
2019-08-02T08:32:44.123Z eslint:rules Loading rule 'no-obj-calls' (remaining=233)
2019-08-02T08:32:44.123Z eslint:rules Loading rule 'no-octal' (remaining=232)
2019-08-02T08:32:44.123Z eslint:rules Loading rule 'no-prototype-builtins' (remaining=231)
2019-08-02T08:32:44.124Z eslint:rules Loading rule 'no-redeclare' (remaining=230)
2019-08-02T08:32:44.127Z eslint:rules Loading rule 'no-regex-spaces' (remaining=229)
2019-08-02T08:32:44.128Z eslint:rules Loading rule 'no-self-assign' (remaining=228)
2019-08-02T08:32:44.129Z eslint:rules Loading rule 'no-shadow-restricted-names' (remaining=227)
2019-08-02T08:32:44.129Z eslint:rules Loading rule 'no-sparse-arrays' (remaining=226)
2019-08-02T08:32:44.129Z eslint:rules Loading rule 'no-this-before-super' (remaining=225)
2019-08-02T08:32:44.130Z eslint:rules Loading rule 'no-undef' (remaining=224)
2019-08-02T08:32:44.131Z eslint:rules Loading rule 'no-unexpected-multiline' (remaining=223)
2019-08-02T08:32:44.131Z eslint:rules Loading rule 'no-unreachable' (remaining=222)
2019-08-02T08:32:44.131Z eslint:rules Loading rule 'no-unsafe-finally' (remaining=221)
2019-08-02T08:32:44.132Z eslint:rules Loading rule 'no-unsafe-negation' (remaining=220)
2019-08-02T08:32:44.132Z eslint:rules Loading rule 'no-unused-labels' (remaining=219)
2019-08-02T08:32:44.132Z eslint:rules Loading rule 'no-unused-vars' (remaining=218)
2019-08-02T08:32:44.135Z eslint:rules Loading rule 'no-useless-catch' (remaining=217)
2019-08-02T08:32:44.135Z eslint:rules Loading rule 'no-useless-escape' (remaining=216)
2019-08-02T08:32:44.136Z eslint:rules Loading rule 'no-with' (remaining=215)
2019-08-02T08:32:44.136Z eslint:rules Loading rule 'require-atomic-updates' (remaining=214)
2019-08-02T08:32:44.137Z eslint:rules Loading rule 'require-yield' (remaining=213)
2019-08-02T08:32:44.138Z eslint:rules Loading rule 'use-isnan' (remaining=212)
2019-08-02T08:32:44.138Z eslint:rules Loading rule 'valid-typeof' (remaining=211)
2019-08-02T08:32:44.139Z eslint:rules Loading rule 'no-var' (remaining=210)
2019-08-02T08:32:44.139Z eslint:rules Loading rule 'prefer-const' (remaining=209)
2019-08-02T08:32:44.141Z eslint:rules Loading rule 'prefer-rest-params' (remaining=208)
2019-08-02T08:32:44.141Z eslint:rules Loading rule 'prefer-spread' (remaining=207)
2019-08-02T08:32:44.144Z eslint:rules Loading rule 'camelcase' (remaining=206)
2019-08-02T08:32:44.148Z eslint:rules Loading rule 'indent' (remaining=205)
2019-08-02T08:32:44.167Z eslint:rules Loading rule 'no-array-constructor' (remaining=204)
2019-08-02T08:32:44.173Z eslint:rules Loading rule 'no-use-before-define' (remaining=203)
2019-08-02T08:32:44.176Z eslint:rules Loading rule 'linebreak-style' (remaining=202)
2019-08-02T08:32:44.177Z eslint:rules Loading rule 'quotes' (remaining=201)
2019-08-02T08:32:44.179Z eslint:rules Loading rule 'semi' (remaining=200)
2019-08-02T08:32:44.181Z eslint:rules Loading rule 'sort-keys' (remaining=199)
2019-08-02T08:32:44.184Z eslint:cascading-config-array-factory Configuration was determined: ConfigArray [ { name: '.eslintrc.js » eslint:recommended', filePath: '/usr/lib/node_modules/eslint/conf/eslint-recommended.js', criteria: null, env: undefined, globals: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, root: undefined, rules: { 'constructor-super': 'error', 'for-direction': 'error', 'getter-return': 'error', 'no-async-promise-executor': 'error', 'no-case-declarations': 'error', 'no-class-assign': 'error', 'no-compare-neg-zero': 'error', 'no-cond-assign': 'error', 'no-const-assign': 'error', 'no-constant-condition': 'error', 'no-control-regex': 'error', 'no-debugger': 'error', 'no-delete-var': 'error', 'no-dupe-args': 'error', 'no-dupe-class-members': 'error', 'no-dupe-keys': 'error', 'no-duplicate-case': 'error', 'no-empty': 'error', 'no-empty-character-class': 'error', 'no-empty-pattern': 'error', 'no-ex-assign': 'error', 'no-extra-boolean-cast': 'error', 'no-extra-semi': 'error', 'no-fallthrough': 'error', 'no-func-assign': 'error', 'no-global-assign': 'error', 'no-inner-declarations': 'error', 'no-invalid-regexp': 'error', 'no-irregular-whitespace': 'error', 'no-misleading-character-class': 'error', 'no-mixed-spaces-and-tabs': 'error', 'no-new-symbol': 'error', 'no-obj-calls': 'error', 'no-octal': 'error', 'no-prototype-builtins': 'error', 'no-redeclare': 'error', 'no-regex-spaces': 'error', 'no-self-assign': 'error', 'no-shadow-restricted-names': 'error', 'no-sparse-arrays': 'error', 'no-this-before-super': 'error', 'no-undef': 'error', 'no-unexpected-multiline': 'error', 'no-unreachable': 'error', 'no-unsafe-finally': 'error', 'no-unsafe-negation': 'error', 'no-unused-labels': 'error', 'no-unused-vars': 'error', 'no-useless-catch': 'error', 'no-useless-escape': 'error', 'no-with': 'error', 'require-atomic-updates': 'error', 'require-yield': 'error', 'use-isnan': 'error', 'valid-typeof': 'error' }, settings: undefined }, { name: '.eslintrc.js » plugin:@typescript-eslint/eslint-recommended', filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js', criteria: null, env: undefined, globals: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, root: undefined, rules: undefined, settings: undefined }, { name: '.eslintrc.js » plugin:@typescript-eslint/eslint-recommended#overrides[0]', filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js', criteria: { includes: [Array], excludes: null, basePath: '/home/deviprsd/Projects/CalendarioFX/Calendario' }, env: undefined, globals: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, root: undefined, rules: { 'getter-return': 'off', 'no-dupe-args': 'off', 'no-dupe-keys': 'off', 'no-unreachable': 'off', 'valid-typeof': 'off', 'no-const-assign': 'off', 'no-new-symbol': 'off', 'no-this-before-super': 'off', 'no-undef': 'off', 'no-dupe-class-members': 'off', 'no-redeclare': 'off', 'no-var': 'error', 'prefer-const': 'error', 'prefer-rest-params': 'error', 'prefer-spread': 'error' }, settings: undefined }, { name: '.eslintrc.js » plugin:@typescript-eslint/recommended » ./configs/base.json', filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.json', criteria: null, env: undefined, globals: undefined, parser: { error: null, filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/parser/dist/parser.js', id: '@typescript-eslint/parser', importerName: '.eslintrc.js » plugin:@typescript-eslint/recommended » ./configs/base.json', importerPath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/configs/base.json' }, parserOptions: { sourceType: 'module' }, plugins: { '@typescript-eslint': [Object] }, processor: undefined, root: undefined, rules: undefined, settings: undefined }, { name: '.eslintrc.js » plugin:@typescript-eslint/recommended', filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/eslint-plugin/dist/index.js', criteria: null, env: undefined, globals: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, root: undefined, rules: { '@typescript-eslint/adjacent-overload-signatures': 'error', '@typescript-eslint/array-type': 'error', '@typescript-eslint/ban-types': 'error', camelcase: 'off', '@typescript-eslint/camelcase': 'error', '@typescript-eslint/class-name-casing': 'error', '@typescript-eslint/explicit-function-return-type': 'warn', '@typescript-eslint/explicit-member-accessibility': 'error', indent: 'off', '@typescript-eslint/indent': 'error', '@typescript-eslint/interface-name-prefix': 'error', '@typescript-eslint/member-delimiter-style': 'error', '@typescript-eslint/no-angle-bracket-type-assertion': 'error', 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-empty-interface': 'error', '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-inferrable-types': 'error', '@typescript-eslint/no-misused-new': 'error', '@typescript-eslint/no-namespace': 'error', '@typescript-eslint/no-non-null-assertion': 'error', '@typescript-eslint/no-object-literal-type-assertion': 'error', '@typescript-eslint/no-parameter-properties': 'error', '@typescript-eslint/no-triple-slash-reference': 'error', 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'warn', 'no-use-before-define': 'off', '@typescript-eslint/no-use-before-define': 'error', '@typescript-eslint/no-var-requires': 'error', '@typescript-eslint/prefer-interface': 'error', '@typescript-eslint/prefer-namespace-keyword': 'error', '@typescript-eslint/type-annotation-spacing': 'error' }, settings: undefined }, { name: '.eslintrc.js', filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js', criteria: null, env: { es6: true, node: true, browser: true }, globals: { Atomics: 'readonly', SharedArrayBuffer: 'readonly' }, parser: { error: null, filePath: '/home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/parser/dist/parser.js', id: '@typescript-eslint/parser', importerName: '.eslintrc.js', importerPath: '/home/deviprsd/Projects/CalendarioFX/Calendario/.eslintrc.js' }, parserOptions: { project: [Object], tsconfigRootDir: './' }, plugins: { '@typescript-eslint': [Object] }, processor: undefined, root: undefined, rules: { indent: [Array], 'linebreak-style': [Array], quotes: [Array], semi: [Array], 'sort-keys': [Array] }, settings: undefined } ] on /home/deviprsd/Projects/CalendarioFX/Calendario/src
2019-08-02T08:32:44.186Z eslint:ignored-paths contains:
2019-08-02T08:32:44.187Z eslint:ignored-paths   target   = "/home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts"
2019-08-02T08:32:44.187Z eslint:ignored-paths   base     = "/home/deviprsd/Projects/CalendarioFX/Calendario"
2019-08-02T08:32:44.187Z eslint:ignored-paths   relative = "src/index.ts"
2019-08-02T08:32:44.187Z eslint:ignored-paths   result   = false
2019-08-02T08:32:44.188Z eslint:cli-engine Lint /home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts
2019-08-02T08:32:44.188Z eslint:linter Linting code for /home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts (pass 1)
2019-08-02T08:32:44.188Z eslint:linter Verify
2019-08-02T08:32:44.188Z eslint:linter With ConfigArray: /home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts
2019-08-02T08:32:44.306Z eslint:linter An error occurred while traversing
2019-08-02T08:32:44.306Z eslint:linter Filename: /home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts
2019-08-02T08:32:44.306Z eslint:linter Line: 1
2019-08-02T08:32:44.306Z eslint:linter Parser Options: { ecmaVersion: 6,
  ecmaFeatures: { globalReturn: false },
  project:
   { extends: './tsconfig.json',
     includes: [ 'src/**/*.ts', 'test/**/*.ts' ] },
  tsconfigRootDir: './',
  sourceType: 'module' }
2019-08-02T08:32:44.306Z eslint:linter Parser Path: /home/deviprsd/Projects/CalendarioFX/Calendario/node_modules/@typescript-eslint/parser/dist/parser.js
2019-08-02T08:32:44.306Z eslint:linter Settings: {}
TypeError: Cannot read property 'loc' of undefined
Occurred while linting /home/deviprsd/Projects/CalendarioFX/Calendario/src/index.ts:1
    at Object.VariableDeclaration [as listener] (/usr/lib/node_modules/eslint/lib/rules/indent.js:1370:69)
    at Program:exit.listenerCallQueue.filter.forEach.nodeInfo (/usr/lib/node_modules/eslint/lib/rules/indent.js:1546:55)
    at Array.forEach (<anonymous>)
    at Program:exit (/usr/lib/node_modules/eslint/lib/rules/indent.js:1546:26)
    at listeners.(anonymous function).forEach.listener (/usr/lib/node_modules/eslint/lib/linter/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/usr/lib/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/usr/lib/node_modules/eslint/lib/linter/node-event-generator.js:253:26)
    at NodeEventGenerator.applySelectors (/usr/lib/node_modules/eslint/lib/linter/node-event-generator.js:282:22)
    at NodeEventGenerator.leaveNode (/usr/lib/node_modules/eslint/lib/linter/node-event-generator.js:305:14)

ESlint config

module.exports = {
    'env': {
        'es6': true,
        'node': true,
        'browser': true
    },
    'extends': [
        'eslint:recommended',
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended'
    ],
    'globals': {
        'Atomics': 'readonly',
        'SharedArrayBuffer': 'readonly'
    },
    'parser': '@typescript-eslint/parser',
    'parserOptions': {
        'project': {
            'extends': './tsconfig.json',
            'includes': [
                "src/**/*.ts",
                "test/**/*.ts"
            ]
        },
        'tsconfigRootDir': './'
    },
    'plugins': ['@typescript-eslint'],
    'rules': {
        'indent': [
            'error',
            4
        ],
        'linebreak-style': [
            'error',
            'unix'
        ],
        'quotes': [
            'error',
            'single'
        ],
        'semi': [
            'error',
            'never'
        ],
        'sort-keys': [
            'error',
            'asc'
        ]
    }
}

Dependencies

{
    "@typescript-eslint/eslint-plugin": "^1.13.0",
    ...
}
package version
@typescript-eslint/parser 1.13.0
TypeScript 3.5.3
ESLint 6.1.0
node 10.16.0
npm 6.10.2
@deviprsd deviprsd added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Aug 2, 2019
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for maintainers to take a look labels Aug 2, 2019
@bradzacher bradzacher added this to the indent rewrite milestone Aug 2, 2019
@bradzacher
Copy link
Member

bradzacher commented Aug 2, 2019

It looks like you're not using our version of indent...

-       'indent': [
+       '@typescript-eslint/indent': [
            'error',
            4
        ],

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed bug Something isn't working labels Aug 2, 2019
@deviprsd
Copy link
Author

deviprsd commented Aug 2, 2019

Yup that fixes it.

@psatler
Copy link

psatler commented Dec 16, 2019

I don't know if this will help other people running into this problem, but I was setting a Typescript React project the other day and I run into this same error when typing const.

TL;DR: I fixed this by adding plugin:prettier/recommended as the last config in the extends array of .eslintrc.js file.

I set up .eslint using the eslint --init CLI. Though, when typing const (like shown at #441 (comment)), it threw me this ESLint: Cannot read property 'loc' of undefined error.

In order to fix this, I needed to add "plugin:prettier/recommended" to the extends array in the .eslintrc.js file. After doing this, the error was gone. So, my extends in the .eslintrc.js file became:

extends: [
    'airbnb',
    'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
    'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
    "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
    "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
  ],

@ghost
Copy link

ghost commented Dec 17, 2019

I don't know if this will help other people running into this problem, but I was setting a Typescript React project the other day and I run into this same error when typing const.

TL;DR: I fixed this by adding plugin:prettier/recommended as the last config in the extends array of .eslintrc.js file.

I set up .eslint using the eslint --init CLI. Though, when typing const (like shown at #441 (comment)), it threw me this ESLint: Cannot read property 'loc' of undefined error.

In order to fix this, I needed to add "plugin:prettier/recommended" to the extends array in the .eslintrc.js file. After doing this, the error was gone. So, my extends in the .eslintrc.js file became:

extends: [
    'airbnb',
    'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
    'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
    "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
    "plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
  ],

Thanks a lot, solved !!

@bradzacher
Copy link
Member

It fixed it because it disabled the base indent rule.
Follow the step that I outlined above, and it'll fix it as well.

I also notice that you are using the airbnb config. This config doesn't support our plugin, so you'll end up with a lot of the wrong rules turned on.

Consider using https://www.npmjs.com/package/eslint-config-airbnb-typescript instead.

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants