Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

object-literal-sort-keys not reporting any warnings (tslint 5.8.0, VSCode) #3495

Closed
vladimir-djokic opened this issue Nov 17, 2017 · 3 comments

Comments

@vladimir-djokic
Copy link

Bug Report

  • TSLint version: 5.8.0
  • TypeScript version: 2.6.1
  • Running TSLint via: VSCode (TSLint extension: 1.0.22)

TypeScript code being linted

const foo: { a: number; b: string } = {
    b: "Hello",
    a: 5,
};

with tslint.json configuration:

{
    "defaultSeverity": "warning",
    "rules": {
        // Core rules.
        "adjacent-overload-signatures": { "severity": "error", "options": [true] },
        "ban-comma-operator": { "severity": "error", "options": [true] },
        "ban-types": [
            true,
            ["String", "Use 'string' instead."]
        ],
        "member-access": { "severity": "error", "options": [true] },
        "member-ordering": [
            true,
            {
                "order": [
                    "public-static-field",
                    "protected-static-field",
                    "private-static-field",

                    "public-instance-field",
                    "protected-instance-field",
                    "private-instance-field",

                    "public-constructor",
                    "protected-constructor",
                    "private-constructor",

                    "public-static-method",
                    "protected-static-method",
                    "private-static-method",

                    "public-instance-method",
                    "protected-instance-method",
                    "private-instance-method"
                ]
            }
        ],
        "no-any": true,
        "no-empty-interface": { "severity": "error", "options": [true] },
        "no-import-side-effect": true,
        "no-inferrable-types": false,
        "no-internal-module": true,
        "no-magic-numbers": true,
        "no-namespace": false,
        "no-non-null-assertion": true,
        "no-parameter-reassignment": { "severity": "error", "options": [true] },
        "no-reference": false,
        "no-unnecessary-type-assertion": { "severity": "error", "options": [true] },
        "no-var-requires": true,
        "only-arrow-functions": {
            "severity": "error",
            "options": [true, "allow-declarations"]
        },
        "prefer-for-of": true,
        "promise-function-async": { "severity": "error", "options": [true] },
        "typedef": [
            true,
            "array-destructuring",
            "arrow-call-signature",
            "arrow-parameter",
            "call-signature",
            "member-variable-declaration",
            "object-destructuring",
            "parameter",
            "property-declaration",
            "variable-declaration"
        ],
        "typedef-whitespace": [
            true,
            {
                "call-signature": "nospace",
                "index-signature": "nospace",
                "parameter": "nospace",
                "property-declaration": "nospace",
                "variable-declaration": "nospace"
            },
            {
                "call-signature": "onespace",
                "index-signature": "onespace",
                "parameter": "onespace",
                "property-declaration": "onespace",
                "variable-declaration": "onespace"
            }
        ],
        "unified-signatures": true,
        // Functionality rules.
        "await-promise": [true, "JQueryPromise"],
        "ban": [
            true,
            "eval",
            {"name": ["*", "forEach"], "message": "Use a regular for loop instead."}
        ],
        "curly": { "severity": "error", "options": [true] },
        "forin": true,
        "import-blacklist": false,
        "label-position": true,
        "no-arg": { "severity": "error", "options": [true] },
        "no-bitwise": { "severity": "error", "options": [true] },
        "no-conditional-assignment": { "severity": "error", "options": [true] },
        "no-console": [
            true,
            "debug",
            "info",
            "time",
            "timeEnd",
            "trace"
        ],
        "no-construct": { "severity": "error", "options": [true] },
        "no-debugger": true,
        "no-duplicate-super": { "severity": "error", "options": [true] },
        "no-duplicate-switch-case": { "severity": "error", "options": [true] },
        "no-duplicate-variable": { "severity": "error", "options": [true] },
        "no-empty": { "severity": "error", "options": [true] },
        "no-eval": { "severity": "error", "options": [true] },
        "no-floating-promises": false, // [true, "JQueryPromise"]
        "no-for-in-array": { "severity": "error", "options": [true] },
        "no-implicit-dependencies": true,
        "no-inferred-empty-object-type": { "severity": "error", "options": [true] },
        "no-invalid-template-strings": { "severity": "error", "options": [true] },
        "no-invalid-this": true,
        "no-misused-new": true,
        "no-null-keyword": { "severity": "error", "options": [true] },
        "no-object-literal-type-assertion": { "severity": "error", "options": [true] },
        "no-return-await": { "severity": "error", "options": [true] },
        "no-shadowed-variable": true,
        "no-sparse-arrays": { "severity": "error", "options": [true] },
        "no-string-literal": { "severity": "error", "options": [true] },
        "no-string-throw": { "severity": "error", "options": [true] },
        "no-submodule-imports": true,
        "no-switch-case-fall-through": { "severity": "error", "options": [true] },
        "no-this-assignment": [
            true,
            {
                "allowed-names": [ "^self$" ]
            }
        ], // true
        "no-unbound-method": true,
        "no-unnecessary-class": [true, "allow-static-only"],
        "no-unsafe-any":  true,
        "no-unsafe-finally": { "severity": "error", "options": [true] },
        "no-unused-expression": { "severity": "error", "options": [true] }, // [true, "allow-fast-null-checks"]
        "no-unused-variable": { "severity": "error", "options": [true] },
        "no-use-before-declare": { "severity": "error", "options": [true] },
        "no-var-keyword": { "severity": "error", "options": [true] },
        "no-void-expression": { "severity": "error", "options": [true] },
        "prefer-conditional-expression": [true, "check-else-if"],
        "prefer-object-spread": { "severity": "error", "options": [true] },
        "radix": true,
        "restrict-plus-operands": true,
        "strict-boolean-expressions": true,
        "strict-type-predicates": true,
        "switch-default": { "severity": "error", "options": [true] },
        "triple-equals": {
            "severity": "error",
            "options": [true, "allow-undefined-check"]
        },
        "typeof-compare": { "severity": "error", "options": [true] },
        "use-default-type-parameter": true,
        "use-isnan": { "severity": "error", "options": [true] },
        // Maintainability rules.
        "cyclomatic-complexity": false, // true
        "deprecation": true,
        "eofline": true,
        "indent": [true, "spaces", 4],
        "linebreak-style": [true, "CRLF"],
        "max-classes-per-file": [
            true,
            5,
            "exclude-class-expressions"
        ],
        "max-file-line-count": [true, 500],
        "max-line-length": [true, 120],
        "no-default-export": true,
        "no-duplicate-imports": true,
        "no-mergeable-namespace": true,
        "no-require-imports": true,
        "object-literal-sort-keys": true,
        "prefer-const": true,
        "trailing-comma": [
            true,
            {
                "multiline": "always",
                "singleline": "never"
            }
        ],
        // Style rules.
        "align": true,
        "array-type": [true, "array"],
        "arrow-parens": true,
        "arrow-return-shorthand": true,
        "binary-expression-operand-order": true,
        "callable-types": true,
        "class-name": true,
        "comment-format": [
            true,
            "check-space",
            "check-uppercase"
        ],
        "completed-docs": false,
        "encoding": true,
        "file-header": false,
        "import-spacing": true,
        "interface-name": [true, "always-prefix"],
        "interface-over-type-literal": true,
        "jsdoc-format": false,
        "match-default-export-name": true,
        "newline-before-return": true,
        "new-parens": true,
        "no-angle-bracket-type-assertion": { "severity": "error", "options": [true] },
        "no-boolean-literal-compare": true,
        "no-consecutive-blank-lines": true,
        "no-irregular-whitespace": true,
        "no-parameter-properties": { "severity": "error", "options": [true] },
        "no-redundant-jsdoc": false,
        "no-reference-import": true,
        "no-trailing-whitespace": { "severity": "error", "options": [true] },
        "no-unnecessary-callback-wrapper": true,
        "no-unnecessary-initializer": true,
        "no-unnecessary-qualifier": true,
        "number-literal-format": true,
        "object-literal-key-quotes": [true, "consistent-as-needed"],
        "object-literal-shorthand": false,
        "one-line": false,
        "one-variable-per-declaration": [true, "ignore-for-loop"],
        "ordered-imports": true,
        "prefer-function-over-method": [true, "allow-public", "allow-protected"],
        "prefer-method-signature": { "severity": "error", "options": [true] },
        "prefer-switch": true,
        "prefer-template": true,
        "quotemark": [true, "double"],
        "return-undefined": true,
        "semicolon": [true, "always"],
        "space-before-function-paren": [
            true,
            {
                "anonymous": "always",
                "named": "never",
                "asyncArrow": "always",
                "method": "never",
                "constructor": "never"
            }
        ],
        "space-within-parens": false,
        "switch-final-break": [true, "always"],
        "type-literal-delimiter": true,
        "variable-name": [
            true,
            "ban-keywords",
            "check-format",
            "allow-pascal-case"
        ],
        "whitespace": [
            true,
            "check-branch",
            "check-decl",
            "check-operator",
            "check-module",
            "check-separator",
            "check-rest-spread",
            "check-type",
            "check-typecast",
            "check-type-operator",
            "check-preblock"
        ]
    }
}

Actual behavior

No warning (green underlines)

Expected behavior

Warning about literals not being sorted.

Note: Just upgraded from a older version of TSLint (4.1.1). I apologize in advance if the issue is with my configuration and lack of understanding of rules.

@ajafff
Copy link
Contributor

ajafff commented Nov 17, 2017

I guess you use Windows or at least \r\n line breaks?
This is a duplicate of #3426. It's already fixed on master, only waiting for the next release.

@vladimir-djokic
Copy link
Author

Correct: I'm on Windows and I do use CRLF for line endings. Thank you for a quick reply :)

@ajafff
Copy link
Contributor

ajafff commented Nov 17, 2017

Closing as a duplicate.
If you really need the lint warning from that rule, you can downgrade to 5.7.0

@ajafff ajafff closed this as completed Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants