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

【bug】TypeError: Cannot read property 'type' of null #2057

Closed
mfoonirlee opened this issue May 14, 2021 · 6 comments
Closed

【bug】TypeError: Cannot read property 'type' of null #2057

mfoonirlee opened this issue May 14, 2021 · 6 comments

Comments

@mfoonirlee
Copy link

mfoonirlee commented May 14, 2021

the following line has some exception when node is null

function isExportNameClass(node) {
return node.type === 'ExportNamedDeclaration' && node.declaration.type === 'ClassDeclaration';
}

https://github.com/benmosher/eslint-plugin-import/blob/e9e755d085111004db2e3a79f2812484f5c0cf4e/src/rules/newline-after-import.js#L50

@mfoonirlee mfoonirlee changed the title 【bug】 【bug】TypeError: Cannot read property 'type' of null May 14, 2021
@martinstark
Copy link

related #2056

@ljharb
Copy link
Member

ljharb commented May 14, 2021

@mfoonirlee can you provide some code that causes the crash?

@joonseokhu
Copy link

joonseokhu commented May 14, 2021

This issue will be fixed by 8d7ec17, dd0e8cb

@ljharb ljharb closed this as completed May 14, 2021
@ljharb
Copy link
Member

ljharb commented May 14, 2021

Duplicate of #2063, then.

@maxmilton
Copy link

Still not fixed with eslint-plugin-import v2.23.1:

Oops! Something went wrong! :(

ESLint: 7.26.0

TypeError: Cannot read property 'type' of null
Occurred while linting /home/max/Projects/ekscss/packages/ekscss/src/types.ts:3
    at isExportNameClass (/home/max/Projects/ekscss/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:51:69)
    at checkForNewLine (/home/max/Projects/ekscss/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:79:45)
    at checkImport (/home/max/Projects/ekscss/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:133:9)
    at /home/max/Projects/ekscss/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/max/Projects/ekscss/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/max/Projects/ekscss/node_modules/eslint/lib/linter/node-event-generator.js:256:26)
    at NodeEventGenerator.applySelectors (/home/max/Projects/ekscss/node_modules/eslint/lib/linter/node-event-generator.js:285:22)
    at NodeEventGenerator.enterNode (/home/max/Projects/ekscss/node_modules/eslint/lib/linter/node-event-generator.js:299:14)
    at CodePathAnalyzer.enterNode (/home/max/Projects/ekscss/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)

Head source of of offending file:

import type { SourceMapGenerator } from 'source-map';
import type { Element as _Element, Middleware } from 'stylis';
import type { xcssTag } from './helpers';

export type { Middleware };

// TODO: Remove?
export interface Element extends _Element {

@ljharb
Copy link
Member

ljharb commented May 15, 2021

@maxmilton see #2077; that will be resolved shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants