Eslint-plugin-import: import/no-relative-parent-imports report incorrectly in 2.20.1

Created on 3 Feb 2020  路  15Comments  路  Source: benmosher/eslint-plugin-import

In version 2.20.1, I start to get errors like:

Relative imports from parent directories are not allowed. Please either pass what ...

for

import React from 'react';

The problem did not occur in 2.20.0.

I use eslint-typescript but since this used to work in 2.20.0 I doubt that this has anything to do with that.

My .eslintrc.js looks like this

parser: '@typescript-eslint/parser',
parserOptions: {
  project: path.resolve(__dirname, './tsconfig.json')
},
plugins: [
  'react',
  'react-hooks'
],
extends: [
  'plugin:@typescript-eslint/recommended',
  'plugin:react/recommended',
  'plugin:import/errors',
  'plugin:import/warnings',
  'plugin:import/typescripts',
]
bug help wanted typescript

Most helpful comment

@ljharb seems like the problem still show up on Windows :(

All 15 comments

What's your tsconfig look like?

This is my tsconfig.json

{
    "compilerOptions": {
        "target": "esnext",
        "lib": [
            "dom",
            "dom.iterable",
            "esnext",
            "webworker",
            "scripthost"
        ],
        "skipLibCheck": true,
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": true,
        "jsx": "preserve",
        "baseUrl": ".",
        "paths": {
            // some module paths, for example "utils": ["./app/utils]
        }
    },
    "include": [
        "./app/**/*.tsx",
        "./app/**/*.ts"
    ],
    "exclude": [
        "./app/index.tsx"
    ]
}

@blacksteed232 can you check and see if this still occurs on latest master?

@ljharb hey would love to, but could you let me know roughly how I can package this and install it locally?

@blacksteed232 temporarily you should be able to npm install --no-save benmosher/eslint-plugin-import

@ljharb yikes, really sorry, I'm behind a firewall so I cannot do this :(

I'm a bit confused; if you can post on github, surely you can download from it?

ah, that codebase is on a remote machine :D. I will spend some time try to setup a repo and test this out later

@ljharb so I have tried to recreate the problem on MacOS and there was no problem. But the first time I saw the problem was on a Windows machine at work so I'll try that and let you know.

EDIT: tested on windows again just to make sure, seems like this bug only happens on Windows. Will give you an update once I can try to plugin from master

I used this repo to test: https://github.com/blacksteed232/config-tester

@ljharb seems like the problem still show up on Windows :(

@blacksteed232 any update?

@ljharb yeah I tried the one on master but the problem still occured

Having the same issue with reflect-metadata

@Heliks can you elaborate?

@ljharb Same problem as described in the issue: import 'reflect-metadata' is reported on windows while it works fine using linux.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xiaodi0003 picture xiaodi0003  路  3Comments

daltonamitchell picture daltonamitchell  路  3Comments

yutin1987 picture yutin1987  路  3Comments

leonid-bauxy picture leonid-bauxy  路  3Comments

silvenon picture silvenon  路  3Comments