import with assert not recognised by linter
The syntax to import JSON modules uses module import assertions, recently added to JS and HTML specs, and supported by Chrome
(ref: tc39/proposal-json-modules, crbug.com/1132413, crbug.com/v8/10958)
import json_object_name from './some_file.json' assert {type : 'json'};
This is not recognised by the JS linter:
Parse error. Semi-colon expected
import shortlink_patterns from './some_file.json' assert {type : 'json'};
^
Same
ERROR - [JSC_PARSE_ERROR] Parse error. Semi-colon expected
import ABI from './abi.json' assert { type: "json" }
Fair warning: The closure-compiler team is not likely to prioritize this because:
- Problems with supporting ES6 import / export have led us to deprioritize support for it and recommend using
goog.module()andgoog.require()instead. - We have never intended to support linting of JSON files.
- Even if we had really good support for ES6 import / export, it would still be a feature request to allow it to handle import of non-JS-module files.
Sorry.
Just to clarify, this bug/FR is just so that the linter recognises the ES6 import statement for json files, not to actually import and lint the JSON.
But I understand that the linter is part of the compiler, so it would technically need the closure compiler to handle ES6 JSON imports...
Thanks for the feedback.