When it comes to the world of import
, JSLint is still catching up according to their own documentation on the matter:
JSLint only recognizes a limited amount of module syntax.
Previously, JSLint did not support import
at all and then later only with the es6
jslint directive. It's great to see that it has incorporated more features now.
Interestingly, the "small but essential subset" does not allow for default import
and named import
on the same line.
However, you can break the import into two lines like so:
import {Auth} from "aws-amplify";
import Amplify from "aws-amplify";
import awsconfig from "./aws-exports";
Amplify.configure(awsconfig);
// If Auth isn't used, let's utilize it to avoid any JSLint errors.
var myAuth = new Auth("something");
myAuth.something(1);
JSLint emphasizes code readability and scanning ease. Perhaps having both types of imports on the same line could cause confusion between named and default imports. The exact reasoning behind this decision is not entirely clear in this context.
Despite its quirks, JSLint remains a valuable tool for maintaining high standards in JavaScript code. While some may suggest using eslint for more modern JavaScript practices, JSLint offers its own benefits in terms of ensuring code quality over time, albeit with some trade-offs in configurability.