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

[naming-convention] Selector or modifier for global variable. (differ local / global) #2608

Closed
3 tasks done
infacto opened this issue Sep 28, 2020 · 1 comment
Closed
3 tasks done
Labels
duplicate This issue or pull request already exists package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@infacto
Copy link

infacto commented Sep 28, 2020

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.
{
  "rules": {
    "@typescript-eslint/naming-convention": [
      "error",
      {
        "selector": "default",
        "format": ["strictCamelCase"]
      },
      {
        "selector": "variable",
        "modifiers": ["const"],
        // I want only global variables be allowed UPPER_CASE. All other variables camelCase.
        "format": ["strictCamelCase", "UPPER_CASE"]
      }
      {
        "selector": "property",
        "format": ["strictCamelCase"],
        "leadingUnderscore": "allow"
      },
      {
        "selector": "property",
        "modifiers": ["static", "readonly"],
        "format": ["strictCamelCase", "UPPER_CASE"]
      },
      {
        "selector": "typeLike",
        "format": ["StrictPascalCase"]
      }
    ]
  }
}
// This is allowed.
const MY_VALUE = 42;

class MyClass {
  myMethod() {
    // This is NOT allowed.
    const ANOTHER_VALUE = 27;

    // This is allowed.
    const anotherValue = 13;
  }
}

Expected Result

An option to select the global variable in a file.

Actual Result

I have no idea how to select global and local variables.

Additional Info

I use vscode eslint extension for viewing the result.

Versions

package version
@typescript-eslint/eslint-plugin 4.2.0
@typescript-eslint/parser 4.2.0
TypeScript 3.9.5
ESLint 7.10.0
node 10.22.0
@infacto infacto added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Sep 28, 2020
@glen-84
Copy link
Contributor

glen-84 commented Sep 28, 2020

Duplicate of #2318.

@bradzacher bradzacher added duplicate This issue or pull request already exists and removed triage Waiting for maintainers to take a look labels Sep 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 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

3 participants