Skip to content

errors when importing default class from js file in tsx file #10

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

Closed
AdrienLemaire opened this issue Nov 22, 2018 · 1 comment
Closed

Comments

@AdrienLemaire
Copy link

  4:24  error  Parse errors in imported module '../ScrollDown': '>' expected. (58:11)  import/no-named-as-default
  4:24  error  Parse errors in imported module '../ScrollDown': '>' expected. (58:11)  import/no-named-as-default-member

A.js

export default class A extends Component {}

B.tsx

import A from "./A";

versions:

  • eslint 5.9.0
  • eslint-import-resolver-typescript 1.1.1
  • eslint-plugin-typescript 0.13.0
  • typescript-eslint-parser 21.0.1
  • typescript 3.1.6

Also created an issue in eslint/typescript-eslint-parser#564 because I'm unclear about where this issue should be fixed.

Note that I tried to ignore import on tsx altogether, without success.

current .eslintrc
extends:
  - eslint-config-with-prettier
  - plugin:redux-saga/recommended
  - plugin:security/recommended

settings:
  react:
    version: 16.6.0
  import/resolver:
    babel-plugin-root-import: {}
    typescript: {} # use <root>/tsconfig.json
  import/parsers:
    typescript-eslint-parser: [ .ts, .tsx ]
  import/ignore:
    - \.tsx$  # Incorrect parse errors


parser: babel-eslint

plugins:
  - immutable
  - import
  - material-ui
  - redux-saga
  - security
  - typescript

parserOptions:
  ecmaVersion: 2018
  sourceType: "module"
  allowImportExportEverywhere: false
  codeFrame: false
  ecmaFeatures:
    legacyDecorators: true
    jsx: true

globals:
  firebase: true
  requirejs: true
  window: true
  _: true
  expect: true
  jest: true
  # enzyme vars (check jestsetup.js)
  shallow: true
  render: true
  mount: true

env:
  amd: true # for require.js (request() and define())
  browser: true
  commonjs: true
  es6: true
  mocha: true

rules:
  class-methods-use-this: 1
  flowtype/no-types-missing-file-annotation: 0
  immutable/no-mutation: 2
  import/named: 1
  import/order: error
  import/no-extraneous-dependencies: 0
  import/no-unresolved: error
  jsx-a11y/anchor-is-valid:
  - error
  - components:
    - Link
    specialLink:
    - to
  no-restricted-syntax:
    - error
    - selector: 'ForInStatement'
      message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.'
    - selector: 'LabeledStatement'
      message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.'
    - selector: 'WithStatement'
      message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.'
  no-else-return:
    - "error"
    - allowElseIf: true
  one-var:
    - error
    - var: "always"
  prefer-destructuring:
    - error
    - object: false
  react/jsx-filename-extension: 0
  react/forbid-foreign-prop-types: 1
  react/prop-types: [2, {skipUndeclared: 1}]
  strict: 0
  typescript/class-name-casing: "error"
  typescript/no-unused-vars: "error"
  typescript/type-annotation-spacing: "error"

overrides:
  - files: ["*.ts", "*.tsx"]
    parser: "typescript-eslint-parser"
    parserOptions:
      ecmaFeatures:
        legacyDecorators: true
        jsx: true
        useJSXTextNode: true
    rules:
      import/no-unresolved: "error"
@bradzacher
Copy link
Collaborator

Hi @Fandekasp - this is a buggy interaction between eslint/typescript-eslint-parser and bradzacher/eslint-plugin-typescript.

The parser released v20/21 which introduced a number of breaking changes, which haven't yet been handled by the plugin. It's being worked on right now though!
If you try downgrading the parser to v15, that's known to work fine.

Closing as this isn't a bug with the import resolver.

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

2 participants