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

no-useless-constructor: Cannot read property 'body' of null #13830

Closed
AriPerkkio opened this issue Nov 10, 2020 · 4 comments · Fixed by #13842
Closed

no-useless-constructor: Cannot read property 'body' of null #13830

AriPerkkio opened this issue Nov 10, 2020 · 4 comments · Fixed by #13842
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

Comments

@AriPerkkio
Copy link
Contributor

no-useless-constructor rule crashes on typescript's declaration files where class constructor has no body. There's also one error included which I believe comes from Flow setup. I'm not that familiar with Flow, but fixing the TS issue should cover Flow as well.

Tell us about your environment

$ ./node_modules/.bin/eslint --env-info
Environment Info:

Node version: v14.15.0
npm version: v6.14.8
Local ESLint version: v7.12.1 (Currently used)
Global ESLint version: Not found

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

Please show your full configuration:

Configuration
    /** ESLint configuration */
    eslintrc: {
        root: true,
        env: {
            es6: true,
            node: true,
        },
        parser: '@typescript-eslint/parser',
        parserOptions: {
            ecmaVersion: 2020,
            sourceType: 'module',
            ecmaFeatures: {
                jsx: true,
            },
        },
        settings: {
            react: {
                version: '16.13.1',
            },
        },
        plugins: ['react', 'react-hooks', 'node', '@typescript-eslint'],
        extends: [
            'eslint:all',
            'plugin:react/all',
            'plugin:react-hooks/recommended',
            'plugin:node/recommended',
            'plugin:@typescript-eslint/recommended',
        ],
    },

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

17 crash reports from various repositories

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:138
  • Path: captbaritone/winamp2-js/packages/webamp/index.d.ts
  • Link
  ) => Track[] | null | Promise<Track[] | null>;
}

export default class Webamp {
  constructor(options: Options);

  /**
   * Returns a true if the current browser supports the features that Webamp depends upon.
   *
   * It is recommended to check this before you attempt to instantiate an instance of Winamp.
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:138
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:28
  • Path: elastic/eui/src/components/text_diff/text-diff.d.ts
  • Link
  type DiffElement = [-1 | 0 | 1, string];

  class Diff {
    constructor({ timeout }: ConstructorProps);
    main: (initialText: string, currentText: string) => DiffElement[];
  }
  export = Diff;
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:28
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:21
  • Path: elastic/kibana/packages/kbn-interpreter/src/common/lib/registry.d.ts
  • Link
 * under the License.
 */

export class Registry<ItemSpec, Item> {
  constructor(prop?: string);

  public wrapper(obj: ItemSpec): Item;

  public register(fn: () => ItemSpec): void;
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:21
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:96
  • Path: elastic/kibana/src/legacy/server/kbn_server.d.ts
  • Link
  public readonly newPlatform: NewPlatform;
  public server: Server;
  public inject: Server['inject'];

  constructor(settings: Record<string, any>, config: KibanaConfig, core: KibanaCore);

  public ready(): Promise<void>;
  public mixin(...fns: KbnMixinFunc[]): Promise<void>;
  public listen(): Promise<Server>;
  public close(): Promise<void>;
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:96
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:39
  • Path: elastic/kibana/src/plugins/vis_type_timelion/server/lib/classes/timelion_function.d.ts
  • Link
}

// eslint-disable-next-line import/no-default-export
export default class TimelionFunction {
  constructor(name: string, config: TimelionFunctionConfig);
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:39
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:36
  • Path: elastic/kibana/src/plugins/vis_type_vega/public/vega_view/vega_base_view.d.ts
  • Link
  // findIndex: (index: string) => Promise<...>;
}

export class VegaBaseView {
  constructor(params: VegaViewParams);
  init(): Promise<void>;
  onError(error: any): void;
  destroy(): Promise<void>;
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:36
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:17
  • Path: elastic/kibana/x-pack/plugins/maps/public/classes/joins/inner_join.d.ts
  • Link
import { IField } from '../fields/field';
import { PropertiesMap } from '../../../common/elasticsearch_util';

export class InnerJoin implements IJoin {
  constructor(joinDescriptor: JoinDescriptor, leftSource: ISource);

  destroy: () => void;

  getRightJoinSource(): ESTermSource;
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:17
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:18
  • Path: elastic/kibana/x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.d.ts
  • Link
}

export class TileLayer extends AbstractLayer {
  static type: string;
  constructor(args: ITileLayerArguments);
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:18
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:29
  • Path: elastic/kibana/x-pack/plugins/ml/public/application/util/time_buckets.d.ts
  • Link
  'dateFormat:scaled': string[][];
}

export declare class TimeBuckets {
  constructor(timeBucketsConfig: TimeBucketsConfig);
  public setBarTarget(barTarget: number): void;
  public setMaxBars(maxBars: number): void;
  public setInterval(interval: string): void;
  public setBounds(bounds: TimeRangeBounds): void;
  public getBounds(): { min: any; max: any };
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:29
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:13
  • Path: FormidableLabs/react-music/interfaces/tunajs.js
  • Link
  PingPongDelay: (options: Object) => Object;
};

declare class Tuna {
  constructor(context: Object): TunaInstance;
}

declare module 'tunajs' {
  declare var exports: typeof Tuna;
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:13
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:26
  • Path: microsoft/fluentui/packages/monaco-editor/monaco-typescript.d.ts
  • Link
// languageFeatures.d.ts
export declare function flattenDiagnosticMessageText(diag: string | ts.DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
export declare abstract class Adapter {
  protected _worker: (first: Uri, ...more: Uri[]) => Promise<TypeScriptWorker>;
  constructor(_worker: (first: Uri, ...more: Uri[]) => Promise<TypeScriptWorker>);
  protected _textSpanToRange(model: monaco.editor.ITextModel, span: ts.TextSpan): monaco.IRange;
}
export declare class DiagnosticsAdapter extends Adapter {
  private _defaults;
  private _selector;
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:26
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:5
  • Path: mui-org/material-ui/packages/material-ui-styles/src/ServerStyleSheets/ServerStyleSheets.d.ts
  • Link
import * as React from 'react';
import { StylesProviderProps } from '../StylesProvider';

declare class ServerStyleSheets {
  constructor(options?: object);
  collect(children: React.ReactNode, options?: object): React.ReactElement<StylesProviderProps>;
  toString(): string;
  getStyleElement(props?: object): React.ReactElement;
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:5
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:2
  • Path: mui-org/material-ui/packages/material-ui-utils/macros/MuiError.macro.d.ts
  • Link
export default class MuiError {
  constructor(message: string);
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:2
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:103
  • Path: pmndrs/react-spring/packages/core/src/SpringValue.ts
  • Link
  /** The last `scheduleProps` call that changed the `to` prop */
  protected _lastToId = 0

  constructor(from: Exclude<T, object>, props?: SpringUpdate<T>)
  constructor(props?: SpringUpdate<T>)
  constructor(arg1?: any, arg2?: any) {
    super()
    if (!is.und(arg1) || !is.und(arg2)) {
      const props = is.obj(arg1) ? { ...arg1 } : { ...arg2, from: arg1 }
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:103
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:12
  • Path: reakit/reakit/packages/website/types/rehype-react.d.ts
  • Link
    };
  };

  export default class RehypeReact {
    constructor(options: Options);

    Compiler: (node: any) => any;
  }
}
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:12
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:687
  • Path: text-mask/text-mask/angular2/typings/globals/node/index.d.ts
  • Link
        maxSockets: number;
        sockets: any;
        requests: any;

        constructor(opts?: AgentOptions);

        /**
         * Destroy any sockets that are currently in use by the agent.
         * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
         * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:687
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Rule: no-useless-constructor

  • Message: Cannot read property 'body' of null Occurred while linting <text>:39
  • Path: withspectrum/spectrum/flow-typed/npm/common-tags_v1.4.x.js
  • Link
  declare export var commaListsAnd: TaggedTemplate;

  // Class for creating a new tagged template literal
  declare export class TemplateTag {
    constructor(): TemplateTag;
    constructor(transformers: Array<TemplateTransformer>): TemplateTag;
    constructor(...transformers: Array<TemplateTransformer>): TemplateTag;
  }

  // Built-in transformers
TypeError: Cannot read property 'body' of null
Occurred while linting <text>:39
    at checkForConstructor (/<removed>/eslint-remote-tester/node_modules/eslint/lib/rules/no-useless-constructor.js:165:42)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
    at /<removed>/eslint-remote-tester/node_modules/eslint/lib/linter/linter.js:952:32
    at Array.forEach (<anonymous>)

Command used to run ESLint:
https://github.com/AriPerkkio/eslint-remote-tester/blob/dd0af730f136ef0fd7be34eb227887f1afa1b7cb/lib/engine/worker-task.ts#L185

What did you expect to happen?
ESlint rule should not crash.

What actually happened? Please include the actual, raw output from ESLint.
TypeError: Cannot read property 'body' of null

const body = node.value.body.body;

Are you willing to submit a pull request to fix this bug?
Yes, I've already started to debug this. Could someone verify this bug before I go any further?

@AriPerkkio AriPerkkio added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Nov 10, 2020
@mdjermanovic mdjermanovic added 3rd party plugin This is an issue related to a 3rd party plugin, config, or parser evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Nov 10, 2020
@mdjermanovic
Copy link
Member

Hi @AriPerkkio, thanks for the issue!

You should use @typescript-eslint/no-useless-constructor rule instead of the core no-useless-constructor rule:

{  
  "no-useless-constructor": "off",
  "@typescript-eslint/no-useless-constructor": ["error"]
}

@AriPerkkio
Copy link
Contributor Author

The @typescript-eslint/no-useless-constructor should work.

This is not really blocking my development or anything. I'm just running a tool I've created and checking stability of well-known ESLint plugins. I'm reporting all findings to plugin developers, if possible.

How about that JS case with Flow typings, https://github.com/FormidableLabs/react-music/blob/HEAD/interfaces/tunajs.js#L13?

@mdjermanovic
Copy link
Member

I'm just running a tool I've created and checking stability of well-known ESLint plugins. I'm reporting all findings to plugin developers, if possible.

Thanks for doing that! eslint-remote-tester looks awesome.

How about that JS case with Flow typings, https://github.com/FormidableLabs/react-music/blob/HEAD/interfaces/tunajs.js#L13?

Did you run the rule with @typescript-eslint/parser? It seems they're using babel-eslint, and this error doesn't happen with babel because it generates a different AST (I tried with several babel-eslint and @babel/eslint-parser versions).

@AriPerkkio
Copy link
Contributor Author

Did you run the rule with @typescript-eslint/parser? It seems they're using babel-eslint

This was indeed spotted with @typescript-eslint/parser. With babel-eslint there are no errors.

It seems that turning off this rule is common when using @typescript-eslint/parser, e.g. in react-app config. As this rule is not included in the eslint:recommended I don't think many will run into this.

I think it is safe to close this issue without taking action. But on the other hand - this was the only rule of eslint:all which crashed when linting 164 repositories. Every other rule seemed stable. Having perfect score would be awesome. 💯

AriPerkkio added a commit to AriPerkkio/eslint that referenced this issue Nov 14, 2020
- Do not crash on parsers which do not require class constructor to have a body
AriPerkkio added a commit to AriPerkkio/eslint that referenced this issue Nov 14, 2020
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators May 18, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants