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

dts lint --write-file outputs absolute path to eslint-config-react-app in .eslintrc.js #118

Closed
igordanchenko opened this issue Dec 23, 2021 · 3 comments

Comments

@igordanchenko
Copy link

Current Behavior

dts lint --write-file produces the following .eslintrc.js in v1.1.3:

module.exports = {
    extends: [
        "/Users/user/my-project/node_modules/dts-cli/conf/eslint-config-react-app/index.js",
        "prettier",
        "plugin:prettier/recommended",
    ],
    settings: {
        react: {
            version: "detect",
        },
    },
};

Expected behavior

dts lint --write-file should not be including absolute paths in the .eslintrc.js

Suggested solution(s)

Output path relative to the project root.

@igordanchenko
Copy link
Author

It's also worth mentioning that there is another issue with ejected .eslintrc.js. I had .eslintrc.js produced by v.0.20.0 that looked like this:

module.exports = {
    extends: ["react-app", "prettier", "plugin:prettier/recommended"],
    settings: {
        react: {
            version: "detect",
        },
    },
};

but it stopped working after upgrading to 1.1.3

Error: Failed to load config "react-app" to extend from.
Referenced from: /Users/user/my-project/.eslintrc.js
    at configInvalidError (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2596:9)
    at ConfigArrayFactory._loadExtendedShareableConfig (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3189:23)
    at ConfigArrayFactory._loadExtends (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3087:25)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3026:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2971:20)
    at _normalizeObjectConfigData.next (<anonymous>)
    at ConfigArrayFactory.loadInDirectory (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2817:28)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3772:46)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/Users/user/my-project/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3791:20) {
  messageTemplate: 'extend-config-missing',
  messageData: {
    configName: 'react-app',
    importerName: '/Users/user/my-project/.eslintrc.js'
  }
}

That's why I went to generate a new .eslintrc.js and ran into this issue with absolute path.

@aladdin-add
Copy link

Some background: eslint-config-react-app v7.0.0 dropped node v12, and it hacked eslint module-resolver - breaks dts lint. So, I forked it to make a few changes, it should be gone away in dts v2.0(thanks to eslint's upcoming new config system).

not sure if there is a better solution but converting to relative path seems a straightforward fix.

@silesky
Copy link

silesky commented Dec 27, 2021

Running into the same issue when attempting to use dts lint at all on 1.1.3.

Error: Failed to load config "prettier" to extend from.
Referenced from: BaseConfig
... {
  messageTemplate: 'extend-config-missing',
  messageData: { configName: 'prettier', importerName: '' }

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

No branches or pull requests

3 participants