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.

TypeError: Cannot read property 'body' of null

See original GitHub issue

Tell us about your environment

  • ESLint Version: 7.8.1
  • Node Version: 12.14.1
  • npm Version: 6.14.5

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

Please show your full configuration:

Configuration
module.exports = {
  root: true,

  env: {
    node: true,
    browser: true
  },

  extends: [
    'plugin:vue/strongly-recommended',
    '@vue/airbnb',
    '@vue/typescript',
    'plugin:prettier/recommended',
    'prettier',
    'prettier/@typescript-eslint',
    'prettier/vue'
  ],

  parserOptions: {
    ecmaVersion: 2020,
    parser: '@typescript-eslint/parser',
    sourceType: 'module'
  },

  rules: {
    'no-console': 'off',
    'no-debugger': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-namespace': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-non-null-assertion': 'off',
    '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
    'class-methods-use-this': 'off',
    'vue/component-name-in-template-casing': ['error', 'PascalCase'],
    'vue/no-v-html': 'off',
    'no-shadow': 'off',
    'vue/max-attributes-per-line': [
      2,
      {
        singleline: 20,
        multiline: {
          max: 1,
          allowFirstLine: false
        }
      }
    ],
    'prettier/prettier': 'warn'
  },

  overrides: [
    {
      files: ['**/*.test.ts'],
      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.

tiptap-extensions.d.ts

declare module 'tiptap-extensions' {
  import { Extension, Node, Mark } from 'tiptap';
  import { Node as PromsemirrorNode } from 'prosemirror-model';

  export interface PlaceholderOptions {
    emptyNodeClass?: string;
    emptyNodeText?: ((node: PromsemirrorNode) => string | undefined) | string;
    showOnlyWhenEditable?: boolean;
    showOnlyCurrent?: boolean;
    emptyEditorClass: string;
  }
  export class Placeholder extends Extension {
    constructor(options?: PlaceholderOptions);
  }

  export interface TrailingNodeOptions {
    /**
     * Node to be at the end of the document
     *
     * defaults to 'paragraph'
     */
    node: string;
    /**
     * The trailing node will not be displayed after these specified nodes.
     */
    notAfter: string[];
  }
  export class TrailingNode extends Extension {
    constructor(options?: TrailingNodeOptions);
  }

  export interface HeadingOptions {
    levels?: number[];
  }

  export class History extends Extension {}

  export class Bold extends Mark {}
  export class Code extends Mark {}
  export class Italic extends Mark {}
  export class Link extends Mark {}
  export class Strike extends Mark {}
  export class Underline extends Mark {}

  export class Blockquote extends Node {}
  export class BulletList extends Node {}
  export class CodeBlock extends Node {}
  export class HardBreak extends Node {}
  export class Heading extends Node {
    constructor(options?: HeadingOptions);
  }
  export class HorizontalRule extends Node {}
  export class Image extends Node {}
  export class ListItem extends Node {}
  export class OrderedList extends Node {}
  export class Table extends Node {}
  export class TableCell extends Node {}
  export class TableRow extends Node {}
  export class TableHeader extends Node {}
  export class TodoItem extends Node {}
  export class TodoList extends Node {}
}
vue-cli-service lint

What did you expect to happen? I expect eslint to tell me there is an error with the file or not without crashing

What actually happened? Please include the actual, raw output from ESLint. ERROR TypeError: Cannot read property ‘body’ of null Occurred while linting \SkyCourt.UI\ui\src\typings\tiptap-extensions.d.ts:13 TypeError: Cannot read property ‘body’ of null Occurred while linting SkyCourt.UI\ui\src\typings\tiptap-extensions.d.ts:13 at checkForConstructor (SkyCourt.UI\ui\node_modules\eslint\lib\rules\no-useless-constructor.js:165:42) at SkyCourt.UI\ui\node_modules\eslint\lib\linter\safe-emitter.js:45:58 at Array.forEach (<anonymous>) at Object.emit (SkyCourt.UI\ui\node_modules\eslint\lib\linter\safe-emitter.js:45:38) at NodeEventGenerator.applySelector (SkyCourt.UI\ui\node_modules\eslint\lib\linter\node-event-generator.js:254:26) at NodeEventGenerator.applySelectors (SkyCourt.UI\ui\node_modules\eslint\lib\linter\node-event-generator.js:283:22) at CodePathAnalyzer.enterNode (SkyCourt.UI\ui\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:711:23) at SkyCourt.UI\ui\node_modules\eslint\lib\linter\linter.js:952:32 at Array.forEach (<anonymous>) at runRules (SkyCourt.UI\ui\node_modules\eslint\lib\linter\linter.js:947:15) at Linter._verifyWithoutProcessors (SkyCourt.UI\ui\node_modules\eslint\lib\linter\linter.js:1173:31) at Linter._verifyWithConfigArray (SkyCourt.UI\ui\node_modules\eslint\lib\linter\linter.js:1271:21) at Linter.verify (SkyCourt.UI\ui\node_modules\eslint\lib\linter\linter.js:1226:25) at Linter.verifyAndFix (SkyCourt.UI\ui\node_modules\eslint\lib\linter\linter.js:1416:29) at verifyText (SkyCourt.UI\ui\node_modules\eslint\lib\cli-engine\cli-engine.js:224:48) error Command failed with exit code 1.

Are you willing to submit a pull request to fix this bug? I don’t presume to understand the eslint code enough to be able to provide a fix.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
gregverescommented, Sep 9, 2020

Yea, that makes sense. I had mistakenly assumed that if somebody was suggesting a config (ie a set of extend packages) that it would have worked out all those kinks and favoured the extension rules. I was wrong, but I am on the right path now. I know what to look for in the future and I have started a set of overrides for .d.ts files in my config.

Thanks again for such a quick response!

0reactions
nzakascommented, Oct 1, 2020

Looks like this is resolved, so closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: TypeError: Cannot read property 'body' of null
But in your case that body element does not exists, and you get the message saying TypeError: Cannot read property 'body' of null...
Read more >
TypeError Cannot read property 'body' of null #661 - GitHub
It's possible that this is a bug in the coverage instrumentation transformation. Do you get this error only when running with --coverage enabled ......
Read more >
Cannot read property `property` of null in 'react-test-renderer ...
Recently, I ran into some problems while attempting to snapshot test my React code. TypeError: Cannot read property 'focus' of null.
Read more >
jest typeerror: cannot read properties of null (reading 'usestate')
Invalid hook call. Hooks can only be called inside of the body of a function component. TypeError: Cannot read properties of null (reading...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
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