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

Decorator: Unexpected use of 'name'. no-restricted-globals #14020

Closed
Edge00 opened this issue Jan 21, 2021 · 5 comments
Closed

Decorator: Unexpected use of 'name'. no-restricted-globals #14020

Edge00 opened this issue Jan 21, 2021 · 5 comments
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion

Comments

@Edge00
Copy link

Edge00 commented Jan 21, 2021

env info

  • ESLint Version: 7.14.0
  • Node Version: 12.13.1
  • npm Version:6.4.10

parser

@typescript-eslint/parser

Configuration
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
    mocha: true,
  },
  parser: '@typescript-eslint/parser',
  extends: ['airbnb-base', 'plugin:@typescript-eslint/recommended'],
  globals: {
    expect: false,
  },
  rules: {
    'no-use-before-define': 0,
    'max-classes-per-file': [0, 1],
    '@typescript-eslint/member-delimiter-style': [2, { multiline: { delimiter: 'none' } }],
    '@typescript-eslint/no-use-before-define': [2],
    '@typescript-eslint/explicit-module-boundary-types': 0,
    '@typescript-eslint/ban-types': 0,
  },
Code
export default class CiController extends Base {
  @post('/docker-image/record')
  async createDockerImageRecord(@parseRequest({
    body: {
      name: {
        type: 'string',
        required: true,
      },
      tag: {
        type: 'string',
        required: true,
      },
      jobId: {
        type: 'number',
        required: true,
      },
      pId: {
        type: 'number',
        required: true,
      },
      packageLockStr: {
        type: 'string',
        required: true,
      },
    },
  }) paramters: {
    body: {
      name: string
      tag: string
      jobId: number
      pId: number
      packageLockStr: string
    }
  }): IResult<any> {
    const {
      name,
      tag,
      jobId,
      pId,
      packageLockStr,
    } = paramters.body

  }
}

command

eslint

result

image

What did you expect to happen?
This is not declaring a variable. Sholdn't trigger this rule

What actually happened? Please include the actual, raw output from ESLint.
/Users/qiongen/Desktop/red/fe-platform/src/app/controller/ci.ts
96:7 error Unexpected use of 'name' no-restricted-globals

✖ 1 problem (1 error, 0 warnings)

Are you willing to submit a pull request to fix this bug?

@Edge00 Edge00 added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jan 21, 2021
@anikethsaha
Copy link
Member

Thanks for the issue.

no-restricted-globals doesnt support ts (and decorators). You can request for the support in [typescript-eslint] (https://github.com/typescript-eslint/typescript-eslint) repo. In the meantime you can disable this rule.

@anikethsaha anikethsaha added 3rd party plugin This is an issue related to a 3rd party plugin, config, or parser evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jan 21, 2021
@mdjermanovic
Copy link
Member

@Edge00 can you try with the latest version of @typescript-eslint/parser?

If there's still a problem, then this would be a bug in @typescript-eslint/scope-manager that should be reported on https://github.com/typescript-eslint/typescript-eslint repo. This rule should work well with TS code as long as the scope analysis is correct.

@JanJakes
Copy link

Seeing this with ESLint 7.18.0 and @typescript-eslint/parser 4.14.0 (latest version).

@mdjermanovic mdjermanovic removed bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 22, 2021
@mdjermanovic
Copy link
Member

I can reproduce this with the latest @typescript-eslint/parser 4.14.0. It doesn't happen with 4.13.0.

It looks like the problem has been already fixed by typescript-eslint/typescript-eslint#2943 as it works well with 4.14.1-alpha.2.

The solution at the moment would be to use 4.13.0 or 4.14.1-alpha.2 until the next version (on Monday).

https://github.com/typescript-eslint/typescript-eslint#package-versions

@Edge00
Copy link
Author

Edge00 commented Jan 25, 2021

@anikethsaha @mdjermanovic Thanks for helping. since this is a bug with typescript-eslint. i'll close this issue. Thanks again!

@Edge00 Edge00 closed this as completed Jan 25, 2021
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jul 25, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd party plugin This is an issue related to a 3rd party plugin, config, or parser archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

No branches or pull requests

4 participants