Skip to content

[no-shadow] enum shadowing when there's nothing else in parent scope? #2733

@mikemaccana

Description

@mikemaccana

I have the following file, twith this as it's only contents:

export enum ProjectOrderByType {
  featuredAt = "featuredAt",
  updatedAt = "updatedAt",
  createdAt = "createdAt",
}

Which fails with:

'ProjectOrderByType' is already declared in the upper scope.

I have read related issues like #2629 and understand this is a charge in eslint v4 https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0

However I do not understand what is being shadowed here - there is nothing else except the export in the parent scope.

  • 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.

Repro

See above

Versions

package version
@typescript-eslint/eslint-plugin 4.6.0
@typescript-eslint/parser 4.6.0
TypeScript 3.9.7
ESLint 7.12.1
node v12.18.3

Config:

module.exports = {
  // Generated with 'npx tslint-to-eslint-config'. See this commit log for the output!
  env: {
    es6: true,
    node: true,
  },
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: "tsconfig.json",
    sourceType: "module",
  },
  plugins: ["@typescript-eslint", "import", "prefer-arrow"],
  rules: {
    "@typescript-eslint/adjacent-overload-signatures": "error",
    "@typescript-eslint/array-type": "error",
    "@typescript-eslint/ban-types": "error",
    // This warns on typeorm migrations
    "@typescript-eslint/class-name-casing": "off",
    "@typescript-eslint/consistent-type-assertions": "off",
    // This triggers too many warnings but we may wish to enable in future
    "@typescript-eslint/explicit-member-accessibility": "off",
    "@typescript-eslint/indent": "off",
    "@typescript-eslint/member-delimiter-style": [
      "off",
      {
        multiline: {
          delimiter: "none",
          requireLast: true,
        },
        singleline: {
          delimiter: "semi",
          requireLast: false,
        },
      },
    ],
    "@typescript-eslint/no-empty-function": "error",
    "@typescript-eslint/no-empty-interface": "error",
    "@typescript-eslint/no-explicit-any": "off",
    "@typescript-eslint/no-misused-new": "error",
    "@typescript-eslint/no-namespace": "error",
    "@typescript-eslint/no-parameter-properties": "off",
    "@typescript-eslint/no-this-alias": "error",
    "@typescript-eslint/no-use-before-define": "off",
    "@typescript-eslint/no-var-requires": "error",
    "@typescript-eslint/prefer-for-of": "error",
    "@typescript-eslint/prefer-function-type": "error",
    "@typescript-eslint/prefer-namespace-keyword": "error",
    "@typescript-eslint/quotes": "off",
    "@typescript-eslint/semi": ["off", null],
    "@typescript-eslint/triple-slash-reference": "error",
    "@typescript-eslint/ban-types": "off",
    "@typescript-eslint/type-annotation-spacing": "off",
    "@typescript-eslint/unified-signatures": "error",
    "arrow-parens": ["off", "as-needed"],
    // Google places, Stripe and third party APIs want snake_case
    // We may wish to enable this in future
    camelcase: "off",
    "comma-dangle": "off",
    complexity: "off",
    "constructor-super": "error",
    "dot-notation": "error",
    "eol-last": "off",
    eqeqeq: ["error", "smart"],
    "guard-for-in": "error",
    "id-blacklist": [
      "error",
      "any",
      "Number",
      "number",
      "String",
      "string",
      "Boolean",
      "boolean",
      "Undefined",
      "undefined",
    ],
    "id-match": "error",
    "import/no-extraneous-dependencies": [
      "error",
      {
        devDependencies: false,
      },
    ],
    "import/no-internal-modules": "error",
    "import/order": "error",
    "linebreak-style": "off",
    "max-classes-per-file": "error",
    "max-len": "off",
    "new-parens": "off",
    "newline-per-chained-call": "off",
    "no-bitwise": "error",
    "no-caller": "error",
    "no-cond-assign": "error",
    "no-console": "error",
    "no-debugger": "error",
    "no-duplicate-case": "error",
    "no-duplicate-imports": "error",
    "no-empty": "error",
    "no-eval": "error",
    "no-extra-bind": "error",
    "no-extra-semi": "off",
    "no-fallthrough": "off",
    "no-invalid-this": "off",
    "no-irregular-whitespace": "off",
    "no-multiple-empty-lines": "off",
    "no-new-func": "error",
    "no-new-wrappers": "error",
    "no-redeclare": "error",
    "no-return-await": "error",
    "no-sequences": "error",
    "no-shadow": [
      "error",
      {
        hoist: "all",
      },
    ],
    "no-sparse-arrays": "error",
    "no-template-curly-in-string": "error",
    "no-throw-literal": "error",
    "no-trailing-spaces": "off",
    "no-undef-init": "error",
    // Some of our APIs use leading underscores, however we might wish to change this in future
    "no-underscore-dangle": "off",
    "no-unsafe-finally": "error",
    "no-unused-expressions": "error",
    "no-unused-labels": "error",
    "no-var": "error",
    "object-shorthand": "error",
    "one-var": ["error", "never"],
    // This plugin will warn if 'function' is used anytime outside an Object's prototype
    "prefer-arrow/prefer-arrow-functions": "off",
    "prefer-const": "error",
    "prefer-object-spread": "error",
    "quote-props": "off",
    radix: "error",
    // "warn" as this needs a lot of fixes (and eslint can't do them for us)
    // https://github.com/eslint/eslint/issues/11924
    // But please do fix these (and change to "error" when we're done!)
    "sort-imports": ["warn", {
      // We seperate groups into libraries, current directory, other directories
      "allowSeparatedGroups": true,
      "ignoreCase": true
    }],
    "space-before-function-paren": "off",
    "space-in-parens": ["off", "never"],
    "spaced-comment": "error",
    "use-isnan": "error",
    "valid-typeof": "off",
  },
  overrides: [
    {
      files: ["src/tasks/*/*.ts"],
      rules: {
        "no-console": "off",
      },
    },
  ],
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix: user errorissue was fixed by correcting the configuration / correcting the codepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions