Description
eslint-plugin-import v2.18.2 throws an error (error Prefer default export import/prefer-default-export) when there are multiple export statements in a typescript file. (this is probably not limited to typescript)
Expected Results
eslint-plugin-import v2.18.1 does not throw this error. This behavior aligns with the example page: prefer-default-export
Basic Example:
export interface SubmitHandler {}
export function anything() {}
// error Prefer default export import/prefer-default-export
Experiencing the same issue with 2.18.1 and above but not with 2.18.0.
I have the issue with the sapper template. Here is a code sample:
import posts from './_posts';
const lookup = new Map();
posts.forEach((post) => {
lookup.set(post.slug, JSON.stringify(post));
});
export function get(req, res) {
const { slug } = req.params;
if (lookup.has(slug)) {
res.writeHead(200, {
'Content-Type': 'application/json',
});
res.end(lookup.get(slug));
} else {
res.writeHead(404, {
'Content-Type': 'application/json',
});
res.end(JSON.stringify({
message: 'Not found',
}));
}
}
Is it related to this issue?
@soullivaneuh in that case, you only have a single named export - so the rule is correctly warning, telling you to make it a default export.
So I just have to do something like this?
export.default = function get(req, res) {
// ...
I don't see any correct match on you examples,
I may open an another issue for that if you want.
No, not like that, like this:
export default function get() {}