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

TypeError: Cannot read property 'meta' of undefined #12093

Closed
Svish opened this issue Aug 13, 2019 · 3 comments
Closed

TypeError: Cannot read property 'meta' of undefined #12093

Svish opened this issue Aug 13, 2019 · 3 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue question This issue asks a question about ESLint

Comments

@Svish
Copy link

Svish commented Aug 13, 2019

Tell us about your environment

  • ESLint Version: 5.16.0
  • Node Version: 12.8.0
  • npm Version: 6.10.2

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

Please show your full configuration:

Configuration
{
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint",
    "chai-friendly",
    "cypress",
    "json",
    "prettier"
  ],
  "extends": [
    "react-app",
    "plugin:cypress/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended",
    "prettier/@typescript-eslint"
  ],
  "rules": {
    "@typescript-eslint/explicit-function-return-type": [
      "warn",
      {
        "allowExpressions": true,
        "allowTypedFunctionExpressions": true,
        "allowHigherOrderFunctions": true
      }
    ]
  },
  "overrides": [
    {
      "files": ["*.spec.*"],
      "rules": {
        "assertion-before-screenshot": true,
        "no-unused-expressions": "off",
        "chai-friendly/no-unused-expressions": "error"
      }
    }
  ]
}

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

I wanted to run ESLint using --fix, but only fix a certain type via --fix-type.

Below is the file it crashes on, but pretty sure it's just because it's the first file it tries doing anything with.

import * as React from 'react';

export interface IfAuthorizedProps {
    isAuthorized: boolean;
}

const IfAuthorized: React.SFC<IfAuthorizedProps> = props => {
    return (
        <If condition={props.isAuthorized}>
            {props.children}
        </If>
    );
};

export default IfAuthorized;
npx eslint --fix --fix-type layout --debug "Content\Scripts\Administrasjon\App\Authorization\IfAuthorized.tsx"

What did you expect to happen?
I expected ESLint to run without issues like it does with --fix.

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

When I add --fix-type, regardless of type specified, it crashes on the first file with the error

TypeError: Cannot read property 'meta' of undefined

Full debug log ``` eslint:cli CLI args: [ '--fix', '--fix-type', 'layout', '--debug', 'Content\\Scripts\\Administrasjon\\App\\Authorization\\IfAuthorized.tsx' ] +0ms eslint:cli Running on files +8ms eslint:cli-engine Using fix types layout +0ms eslint:glob-utils Creating list of files to process. +0ms eslint:ignored-paths baseDir = "C:\\dev\\projects\\portal\\OPF.Portal.Web" +0ms eslint:ignored-paths addPatternRelativeToCwd: eslint:ignored-paths original = "/node_modules/*" eslint:ignored-paths cooked = "/node_modules/*" +1ms eslint:ignored-paths addPatternRelativeToCwd: eslint:ignored-paths original = "/bower_components/*" eslint:ignored-paths cooked = "/bower_components/*" +1ms eslint:ignored-paths addPatternRelativeToCwd: eslint:ignored-paths original = ".*" eslint:ignored-paths cooked = ".*" +0ms eslint:ignored-paths addPatternRelativeToCwd: eslint:ignored-paths original = "!../" eslint:ignored-paths cooked = "!../" +0ms eslint:ignored-paths Looking for ignore file in C:\dev\projects\portal\OPF.Portal.Web +4ms eslint:ignored-paths Could not find ignore file in cwd +0ms eslint:ignored-paths contains: +4ms eslint:ignored-paths target = "C:\\dev\\projects\\portal\\\Content\\Scripts\\Administrasjon\\App\\Authorization\\IfAuthorized.tsx" +0ms eslint:ignored-paths result = false +0ms eslint:ignored-paths contains: +1ms eslint:ignored-paths target = "C:\\dev\\projects\\portal\\\Content\\Scripts\\Administrasjon\\App\\Authorization\\IfAuthorized.tsx" +0ms eslint:ignored-paths result = false +0ms eslint:cli-engine Processing C:\dev\projects\portal\Content\Scripts\Administrasjon\App\Authorization\IfAuthorized.tsx +15ms eslint:cli-engine Linting C:\dev\projects\portal\Content\Scripts\Administrasjon\App\Authorization\IfAuthorized.tsx +1ms eslint:config Constructing config file hierarchy for C:\dev\projects\portal\Content\Scripts\Administrasjon\App\Authorization +0ms eslint:config Using .eslintrc and package.json files +0ms eslint:config Loading C:\dev\projects\portal\package.json +6ms eslint:config-file Loading package.json config file: C:\dev\projects\portal\package.json +0ms eslint:config-file Loading JSON config file: C:\dev\projects\portal\package.json +0ms eslint:config-file Loading @opf/eslint-config +30ms eslint:config-file Attempting to resolve @opf/eslint-config +9ms eslint:config-file Loading JSON config file: C:\dev\projects\portal\node_modules\@opf\eslint-config\.eslintrc.json +2ms eslint:plugins Loaded plugin @typescript-eslint (@typescript-eslint/eslint-plugin@1.13.0) (from C:\dev\projects\portal\node_modules\@typescript-eslint\eslint-plugin\dist\index.js) +0ms eslint:plugins Loaded plugin chai-friendly (eslint-plugin-chai-friendly@0.4.1) (from C:\dev\projects\portal\node_modules\eslint-plugin-chai-friendly\lib\index.js) +9ms eslint:plugins Loaded plugin cypress (eslint-plugin-cypress@2.6.1) (from C:\dev\projects\portal\node_modules\eslint-plugin-cypress\index.js) +6ms eslint:plugins Loaded plugin json (eslint-plugin-json@1.4.0) (from C:\dev\projects\portal\node_modules\eslint-plugin-json\lib\index.js) +53ms eslint:plugins Loaded plugin prettier (eslint-plugin-prettier@3.1.0) (from C:\dev\projects\portal\node_modules\eslint-plugin-prettier\eslint-plugin-prettier.js) +7ms eslint:config-file Loading prettier/@typescript-eslint +387ms eslint:config-file Attempting to resolve eslint-config-prettier/@typescript-eslint +1ms eslint:config-file Loading JS config file: C:\dev\projects\portal\node_modules\eslint-config-prettier\@typescript-eslint.js +3ms eslint:config-file Loading plugin:prettier/recommended +1ms eslint:config-file Attempting to resolve eslint-plugin-prettier +1ms eslint:config-file Loading JS config file: C:\dev\projects\portal\node_modules\eslint-plugin-prettier\eslint-plugin-prettier.js +0ms eslint:config-file Loading prettier +3ms eslint:config-file Attempting to resolve eslint-config-prettier +1ms eslint:config-file Loading JS config file: C:\dev\projects\portal\node_modules\eslint-config-prettier\index.js +8ms eslint:config-file Loading plugin:@typescript-eslint/recommended +3ms eslint:config-file Attempting to resolve @typescript-eslint/eslint-plugin +0ms eslint:config-file Loading JS config file: C:\dev\projects\portal\node_modules\@typescript-eslint\eslint-plugin\dist\index.js +0ms eslint:config-file Loading C:\dev\projects\portal\node_modules\@typescript-eslint\eslint-plugin\dist\configs\base.json +65ms eslint:config-file Loading JSON config file: C:\dev\projects\portal\node_modules\@typescript-eslint\eslint-plugin\dist\configs\base.json +2ms eslint:config-file Loading plugin:cypress/recommended +1ms eslint:config-file Attempting to resolve eslint-plugin-cypress +0ms eslint:config-file Loading JS config file: C:\dev\projects\portal\node_modules\eslint-plugin-cypress\index.js +0ms eslint:config-file Loading react-app +2ms eslint:config-file Attempting to resolve eslint-config-react-app +1ms eslint:config-file Loading JS config file: C:\dev\projects\portal\node_modules\eslint-config-react-app\index.js +2ms eslint:plugins Loaded plugin import (eslint-plugin-import@2.18.2) (from C:\dev\projects\portal\node_modules\eslint-plugin-import\lib\index.js) +248ms eslint:plugins Loaded plugin flowtype (eslint-plugin-flowtype@2.50.3) (from C:\dev\projects\portal\node_modules\eslint-plugin-flowtype\dist\index.js) +89ms eslint:plugins Loaded plugin jsx-a11y (eslint-plugin-jsx-a11y@6.2.3) (from C:\dev\projects\portal\node_modules\eslint-plugin-jsx-a11y\lib\index.js) +358ms eslint:plugins Loaded plugin react (eslint-plugin-react@7.14.3) (from C:\dev\projects\portal\node_modules\eslint-plugin-react\index.js) +116ms eslint:plugins Loaded plugin react-hooks (eslint-plugin-react-hooks@1.7.0) (from C:\dev\projects\portal\node_modules\eslint-plugin-react-hooks\index.js) +5ms eslint:config Using C:\dev\projects\portal\package.json +1s eslint:config-ops Using config from partial cache +0ms eslint:config-ops Apply environment settings to config +0ms eslint:config-ops Creating config for environment browser +1ms eslint:config-ops Creating config for environment commonjs +0ms eslint:config-ops Creating config for environment es6 +1ms eslint:config-ops Creating config for environment jest +0ms eslint:config-ops Creating config for environment node +0ms eslint:config-ops Creating config for environment cypress/globals +0ms eslint:linter Linting code for C:\dev\projects\portal\Content\Scripts\Administrasjon\App\Authorization\IfAuthorized.tsx (pass 1) +0ms eslint:linter Generating fixed text for C:\dev\projects\portal\Content\Scripts\Administrasjon\App\Authorization\IfAuthorized.tsx (pass 1) +10s eslint:source-code-fixer Applying fixes +0ms eslint:source-code-fixer Found fixes to apply +1ms TypeError: Cannot read property 'meta' of undefined at CLIEngine.options.fix (C:\dev\projects\portal\node_modules\eslint\lib\cli-engine.js:499:38) at Function.SourceCodeFixer.applyFixes (C:\dev\projects\portal\node_modules\eslint\lib\util\source-code-fixer.js:122:52) at Linter.verifyAndFix (C:\dev\projects\portal\node_modules\eslint\lib\linter.js:1050:43) at processText (C:\dev\projects\portal\node_modules\eslint\lib\cli-engine.js:197:32) at processFile (C:\dev\projects\portal\node_modules\eslint\lib\cli-engine.js:241:12) at C:\dev\projects\portal\node_modules\eslint\lib\cli-engine.js:616:40 at Array.map () at CLIEngine.executeOnFiles (C:\dev\projects\portal\node_modules\eslint\lib\cli-engine.js:588:34) at Object.execute (C:\dev\projects\portal\node_modules\eslint\lib\cli.js:205:111) at Object. (C:\dev\projects\portal\node_modules\eslint\bin\eslint.js:78:28) ```

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

Tried adding two debug statements where the crash happens:

            this.options.fix = lintResult => {
                const rule = this._rulesCache.get(lintResult.ruleId);
                debug(`lintResult: %O`, lintResult);
                debug(`rule: %O`, rule);
                const matches = rule.meta && fixTypes.has(rule.meta.type);

                return matches && originalFix(lintResult);
            };

Which results in this output:

  eslint:cli-engine lintResult: {
  eslint:cli-engine   ruleId: 'prettier/prettier',
  eslint:cli-engine   severity: 2,
  eslint:cli-engine   message: 'Delete `··`',
  eslint:cli-engine   line: 4,
  eslint:cli-engine   column: 3,
  eslint:cli-engine   nodeType: null,
  eslint:cli-engine   endLine: 4,
  eslint:cli-engine   endColumn: 5,
  eslint:cli-engine   fix: { range: [ 72, 74 ], text: '' }
  eslint:cli-engine } +10s
  eslint:cli-engine rule: undefined +1ms

So rule is for some reason undefined, but, other than that, I wouldn't even know where to begin, so... willing, sort of, but skills and knowledge, no...

@Svish Svish added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Aug 13, 2019
@mysticatea
Copy link
Member

Thank you for your report.

Sounds like a duplicate of #11586. Please try the latest ESLint.

@mysticatea mysticatea added question This issue asks a question about ESLint and removed bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Aug 13, 2019
@Svish
Copy link
Author

Svish commented Aug 14, 2019

Need facebook/create-react-app#7529 to be fixed first for that, because it's blocking our upgrade to ESLint 6, but will once that's resolved. 🙂👍

@eslint-deprecated
Copy link

It looks like the conversation is stalled here. As this is a question rather
than an action item, I'm closing the issue. If you still need help, please send
a message to our mailing list or
chatroom. Thanks!
[//]: # (auto-close)

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 13, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

2 participants