question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint breaks `.d.ts` files

See original GitHub issue

Tell us about your environment

  • ESLint Version: 6.8.0
  • Node Version: v12.16.1
  • npm Version: 6.13.4

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  extends: [
    '@nuxtjs/eslint-config-typescript',
    'prettier',
    'prettier/vue',
    'plugin:prettier/recommended',
    'plugin:nuxt/recommended'
  ],
  plugins: [
    'prettier'
  ],
  // add your custom rules here
  rules: {
  },
  ignorePatterns: ["docs/"]
}

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


declare module '*/office.gql' {
  import { DocumentNode } from 'graphql';
  const defaultDocument: DocumentNode;
  export const AllOffices: DocumentNode;

  export default defaultDocument;
}
    

declare module '*/p-graphql.gql' {
  import { DocumentNode } from 'graphql';
  const defaultDocument: DocumentNode;
  export const HelloMessage: DocumentNode;
export const HelloValue1: DocumentNode;
export const HelloValue2: DocumentNode;
export const HelloValue3: DocumentNode;
export const Hi: DocumentNode;
export const HelloAndHi: DocumentNode;

  export default defaultDocument;
}
yarn eslint --fix xxx.d.ts

What did you expect to happen?

declare module '*/office.gql' {
    import { DocumentNode } from 'graphql';
    const defaultDocument: DocumentNode;
    export const AllOffices: DocumentNode;

    export default defaultDocument;
}

declare module '*/p-graphql.gql' {
    import { DocumentNode } from 'graphql';
    const defaultDocument: DocumentNode;
    export const HelloMessage: DocumentNode;
    export const HelloValue1: DocumentNode;
    export const HelloValue2: DocumentNode;
    export const HelloValue3: DocumentNode;
    export const Hi: DocumentNode;
    export const HelloAndHi: DocumentNode;

    export default defaultDocument;
}

What actually happened? Please include the actual, raw output from ESLint.

declare module '*/office.gql' {
    import { DocumentNode, DocumentNode } from 'graphql';
    const defaultDocument: DocumentNode;
    export const AllOffices: DocumentNode;

    export default defaultDocument;
}

declare module '*/p-graphql.gql' {
    const defaultDocument: DocumentNode;
    export const HelloMessage: DocumentNode;
    export const HelloValue1: DocumentNode;
    export const HelloValue2: DocumentNode;
    export const HelloValue3: DocumentNode;
    export const Hi: DocumentNode;
    export const HelloAndHi: DocumentNode;

    export default defaultDocument;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Apr 15, 2020

@dora-gt thanks for the issue!

This seems to be caused by a third-party rule: import/no-duplicates

Please create an issue in the eslint-plugin-import repository:

https://github.com/benmosher/eslint-plugin-import

0reactions
dora-gtcommented, Apr 15, 2020

Disabling import/no-duplicates worked! Thank you so much 🙇 I’ll report there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is eslint throwing error for .d.ts files in my node project
I have configured eslint for my typescript node project. There is also a file app.d.ts in the repo. On running the lint, I...
Read more >
How to use ESLint with TypeScript | Khalil Stemmler
ESLint is a JavaScript linter that you can use to lint either TypeScript or JavaScript code. In this post, we'll walk through how...
Read more >
The starting point for learning TypeScript
Learn how to write declaration files to describe existing JavaScript. Important for DefinitelyTyped contributions. Introduction · Declaration Reference ...
Read more >
Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
eslint-import-resolver-typescript | Yarn - Package Manager
eslint -import-resolver-typescript · import / require files with extension .cts / .mts / .ts / .tsx / .d.cts / .d.mts / .d.ts ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found