Skip to content

[no-magic-numbers] False positive for negative readonly class properties #1070

@mustafa-cosar

Description

@mustafa-cosar

Repro

{
  "rules": {
    '@typescript-eslint/no-magic-numbers': [
            'error',
            {
                'ignore': [-1, 0, 1, 2],
                'ignoreEnums': true,
                'ignoreNumericLiteralTypes': true,
                'ignoreReadonlyClassProperties': true
            }
        ],
    'no-magic-numbers': 'off',
  }
}
export class Class
{
    public static readonly NEGATIVE_NUMBER = -127;
}

Expected Result
No @typescript-eslint/no-magic-numbers error for either number

Actual Result
[@typescript-eslint/no-magic-numbers] No magic number: -127. but not for the positive number

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.3.2
@typescript-eslint/parser 2.3.2
TypeScript 3.6.3
ESLint 6.5.1
node v10.16.3
npm 6.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: 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