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

[@typescript-eslint/no-unused-vars] define interface in declare global namespace #2292

Closed
tjx666 opened this issue Jul 13, 2020 · 1 comment
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@tjx666
Copy link

tjx666 commented Jul 13, 2020

Repro

const { resolve } = require;
const OFF = 0;
const ERROR = 2;

module.exports = {
    env: {
        browser: true,
        es6: true,
        node: true,
        webextensions: true,
    },
    extends: [
        'airbnb',
        'airbnb/hooks',
        'plugin:eslint-comments/recommended',
        'plugin:import/typescript',
        'plugin:react/recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:unicorn/recommended',
        'plugin:promise/recommended',
        'prettier',
        'prettier/react',
        'prettier/@typescript-eslint',
    ],
    globals: {
        Atomics: 'readonly',
        SharedArrayBuffer: 'readonly',
    },
    parser: '@typescript-eslint/parser',
    parserOptions: {
        ecmaFeatures: {
            jsx: true,
        },
        ecmaVersion: 2020,
        sourceType: 'module',
    },
    plugins: ['@typescript-eslint', 'react', 'unicorn', 'promise'],
    settings: {
        'import/resolver': {
            node: {
                extensions: ['.ts', '.tsx', '.js', '.json'],
            },
            typescript: {
                directory: [resolve('./src/tsconfig.json'), resolve('./server/tsconfig.json')],
            },
        },
    },
    rules: {
        'eslint-comments/disable-enable-pair': [ERROR, { allowWholeFile: true }],

        'import/extensions': OFF,

        'react/jsx-indent': [ERROR, 4],
        'react/jsx-filename-extension': [ERROR, { extensions: ['.ts', '.tsx', '.json', '.js'] }],

        'unicorn/filename-case': [
            ERROR,
            {
                cases: {
                    camelCase: true,
                    pascalCase: true,
                },
            },
        ],
        'unicorn/no-process-exit': OFF,
        'unicorn/prevent-abbreviations': OFF,

        '@typescript-eslint/explicit-function-return-type': OFF,
        '@typescript-eslint/no-explicit-any': OFF,
        '@typescript-eslint/no-non-null-assertion': OFF,
        '@typescript-eslint/no-useless-constructor': ERROR,

        'func-names': OFF,
        'lines-between-class-members': OFF,
        'max-classes-per-file': OFF,
        'no-console': OFF,
        'no-empty': OFF,
        'no-underscore-dangle': OFF,
        'no-unused-expressions': OFF,
        'no-useless-constructor': OFF,
    },
    overrides: [
        {
            files: ['**/*.d.ts'],
            rules: {
                'import/no-duplicates': OFF,
            },
        },
        {
            files: ['server/**/*.ts'],
            rules: {
                'global-require': OFF,

                '@typescript-eslint/no-var-requires': OFF,

                'import/no-dynamic-require': OFF,
                'import/no-extraneous-dependencies': OFF,
            },
        },
    ],
};
import Path from 'path';
import puppeteer, { Browser } from 'puppeteer';

declare global {
    namespace NodeJS {
      interface Global {
        browser: Browser;
      }
    }
}

Expected Result

no error and warning.

Actual Result

'Browser' is defined but never used.

screenshot_2020-07-13_23-03-53

Additional Info

Did eslint throw an exception?

No.

screenshot_2020-07-13_23-09-30

Please run your lint again with the --debug flag, and dump the output below.
i.e. eslint --ext ".ts,.js" src --debug

Versions

package version
@typescript-eslint/eslint-plugin 3.6.0
@typescript-eslint/parser 3.6.0
TypeScript 3.9.6
ESLint 7.4.0
node 12.18.2
npm 6.14.5
yarn 1.21.1
@tjx666 tjx666 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jul 13, 2020
@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Jul 13, 2020
@bradzacher
Copy link
Member

Please use the search before filing new issues
#2026, #2287, #1678, #1596, #1302, etc.

https://github.com/typescript-eslint/typescript-eslint/issues?q=is%3Aissue+%22no-unused-vars%22+global+

Also please read the pinned issues before filing new issues - #1856

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

2 participants