简体   繁体   中英

JSLint : Unexpected ']' in array of object

I'm using JSLint in PHPStorm with ES6 and I have this error after the line : pathPublic + "/css/style.css",

JSLint: Unexpected ']'.

My code :

    let filesCss = [
    {
        outputFilename: "fc-main.min.css",
        outputPath: pathPublic + "/css",
        inputFiles: [
            pathPublic + "/css/style.css",
        ],
    },
];

The trailing commas can hisotrically give issues on older IE versions:

The "Extra comma. (it breaks older versions of IE)" error (and the alternative "Trailing comma" and "Unexpected ',' errors") are thrown when JSLint, JSHint and ESLint encounter a comma following the final element of an array literal or a comma following the final value in an object literal. Since version 2.0.0 JSHint will only raise this warning if the es3 option is set to true.

So you have to remove them or use the es<version> option:

    let filesCss = [
    {
        outputFilename: "fc-main.min.css",
        outputPath: pathPublic + "/css",
        inputFiles: [
            pathPublic + "/css/style.css"
        ]
    }
];

See: https://github.com/jamesallardice/jslint-error-explanations/blob/master/message-articles/extra-comma.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM