How to fix Definition for rule typescript-eslint no-use-before-declare was not found eslint typescript-eslint no-use-before-declare

0 votes

I am new to eslint and I cannot figure out how to solve this issue. The beginning of my imports is always underlined with a red line. It complains about the definition not being found for the specified rule. I would like to keep the rule in place as it is seems it will be otherwise useful.

image

For my .eslintrc.js file I have the following rules set up:

module.exports = {
    env: {
        browser: true,
        node: true
    },
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:@typescript-eslint/recommended-requiring-type-checking',
        'prettier'
    ],
    parser: '@typescript-eslint/parser',
    parserOptions: {
        project: 'tsconfig.json',
        sourceType: 'module'
    },
    plugins: ['@typescript-eslint', '@typescript-eslint/tslint'],
    rules: {
        '@typescript-eslint/class-name-casing': 'error',
        '@typescript-eslint/consistent-type-definitions': 'error',
        '@typescript-eslint/explicit-member-accessibility': [
            'off',
            {
                accessibility: 'explicit'
            }
        ],
        '@typescript-eslint/indent': ['error', 'tab'],
        '@typescript-eslint/member-delimiter-style': [
            'error',
            {
                multiline: {
                    delimiter: 'semi',
                    requireLast: true
                },
                singleline: {
                    delimiter: 'semi',
                    requireLast: false
                }
            }
        ],
        '@typescript-eslint/member-ordering': 'error',
        '@typescript-eslint/no-empty-function': 'off',
        '@typescript-eslint/no-empty-interface': 'error',
        '@typescript-eslint/no-inferrable-types': 'error',
        '@typescript-eslint/no-misused-new': 'error',
        '@typescript-eslint/no-non-null-assertion': 'error',
        '@typescript-eslint/no-use-before-declare': ['error', { functions: true, classes: true, variables: true }],
        '@typescript-eslint/prefer-function-type': 'error',
        '@typescript-eslint/quotes': ['error', 'single'],
        '@typescript-eslint/semi': ['error', 'always'],
        '@typescript-eslint/type-annotation-spacing': 'error',
        '@typescript-eslint/unified-signatures': 'error',
        'arrow-body-style': 'error',
        camelcase: 'off',
        'capitalized-comments': 'error',
        'constructor-super': 'error',
        curly: 'error',
        'dot-notation': 'off',
        'eol-last': 'error',
        eqeqeq: ['error', 'smart'],
        'guard-for-in': 'error',
        'id-blacklist': 'off',
        'id-match': 'off',
        'import/no-deprecated': 'warn',
        'max-classes-per-file': ['error', 1],
        'max-len': [
            'error',
            {
                code: 140
            }
        ],
        'no-bitwise': 'error',
        'no-caller': 'error',
        'no-console': [
            'error',
            {
                allow: [
                    'log',
                    'warn',
                    'dir',
                    'timeLog',
                    'assert',
                    'clear',
                    'count',
                    'countReset',
                    'group',
                    'groupEnd',
                    'table',
                    'dirxml',
                    'error',
                    'groupCollapsed',
                    'Console',
                    'profile',
                    'profileEnd',
                    'timeStamp',
                    'context'
                ]
            }
        ],
        'no-debugger': 'error',
        'no-empty': 'off',
        'no-eval': 'error',
        'no-fallthrough': 'error',
        'no-new-wrappers': 'error',
        'no-shadow': [
            'error',
            {
                hoist: 'all'
            }
        ],
        'no-throw-literal': 'error',
        'no-trailing-spaces': 'error',
        'no-undef-init': 'error',
        'no-underscore-dangle': 'off',
        'no-unused-expressions': 'error',
        'no-unused-labels': 'error',
        'no-var': 'error',
        'prefer-const': 'error',
        radix: 'error',
        'spaced-comment': 'error',
        '@typescript-eslint/tslint/config': [
            'error',
            {
                rules: {
                    'component-class-suffix': [true, 'Component', 'View', 'Routing'],
                    'contextual-lifecycle': true,
                    'directive-class-suffix': true,
                    'import-blacklist': [true, 'rxjs/Rx'],
                    'import-spacing': true,
                    'no-host-metadata-property': true,
                    'no-input-rename': true,
                    'no-inputs-metadata-property': true,
                    'no-output-on-prefix': true,
                    'no-output-rename': true,
                    'no-outputs-metadata-property': true,
                    'no-redundant-jsdoc': true,
                    'one-line': [true, 'check-open-brace', 'check-catch', 'check-else', 'check-whitespace'],
                    'template-banana-in-box': true,
                    'template-no-negated-async': true,
                    'use-component-view-encapsulation': true,
                    'use-lifecycle-interface': true,
                    'use-pipe-decorator': true,
                    'use-pipe-transform-interface': true,
                    'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: false }],
                    whitespace: [true, 'check-branch', 'check-decl', 'check-operator', 'check-separator', 'check-type']
                }
            }
        ]
    }
};

Any idea how to fix this other than removing the rule?

May 31, 2022 in TypeSript by Logan
• 2,140 points
19,088 views

1 answer to this question.

0 votes

Well according to this page, this rule is discouraged as modern TypeScript does not use it and is slow to compute. So you should remove this depricated rule.

If however you still want to keep using it, you can try something like 

{ "no-use-before-define": ["error", { "variables": false }] }

Try referencing more about this here

answered Jun 1, 2022 by Nina
• 3,060 points

Related Questions In TypeSript

0 votes
1 answer

How to declare and initialize a Dictionary in Typescript

Apparently this doesn't work when passing the ...READ MORE

answered May 31, 2022 in TypeSript by Nina
• 3,060 points
6,532 views
0 votes
1 answer

How to use moment.js library in angular 2 typescript app?

REFERENCE: https://momentjs.com/docs/#/use-it/typescript/ You can install this by using: npm install ...READ MORE

answered Jun 1, 2022 in TypeSript by Nina
• 3,060 points
1,686 views
0 votes
1 answer

How to get TypeScript definition files via bower?

The best option is to use tsd. It ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
593 views
0 votes
1 answer

how to use spread syntax and new Set() with TypeScript

The ... operator should work on anything ...READ MORE

answered Jun 10, 2022 in TypeSript by Nina
• 3,060 points
501 views
0 votes
1 answer
0 votes
0 answers

Angular & eslint - Definition for rule '@typescript-eslint/space-infix-ops' was not found

I recently removed the tslint from my ...READ MORE

Aug 1, 2022 in TypeSript by Elton
• 400 points
1,140 views
0 votes
1 answer

Cannot access web3 object with typescript and ethereum

You still need to instantiate it first. ...READ MORE

answered Sep 25, 2018 in Blockchain by slayer
• 29,370 points
2,906 views
0 votes
1 answer

How to apply zoom animation for each element of a list in angular?

Hey @Sid, do check if this link ...READ MORE

answered Jul 30, 2019 in Others by Vardhan
• 13,150 points
1,586 views
0 votes
1 answer

Definition for rule '@typescript-eslint/no-shadow' was not found

v2.34.0 of the typescript-eslint packages is 9 months ...READ MORE

answered Jun 13, 2022 in TypeSript by Nina
• 3,060 points
4,521 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP