Files
NapCatQQ/.pnpm-store/v3/files/05/c5ad760eaae9ee6b057f2dadb80294d0e2fb69919f4a5974767d1e519e469633da1c9da081617389fe382a2a544a9522bd7232738b014bbaa4d8b1bd221ce2
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

56 lines
2.0 KiB
Plaintext

import { createRule, getValue, sourceType } from '../utils/index.js';
export default createRule({
name: 'no-default-export',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Forbid default exports.',
},
schema: [],
messages: {
preferNamed: 'Prefer named exports.',
noAliasDefault: 'Do not alias `{{local}}` as `default`. Just export `{{local}}` itself instead.',
},
},
defaultOptions: [],
create(context) {
if (sourceType(context) !== 'module') {
return {};
}
const { sourceCode } = context;
return {
ExportDefaultDeclaration(node) {
const { loc } = sourceCode.getFirstTokens(node)[1] || {};
context.report({
node,
messageId: 'preferNamed',
loc,
});
},
ExportNamedDeclaration(node) {
for (const specifier of node.specifiers.filter(specifier => getValue(specifier.exported) === 'default')) {
const { loc } = sourceCode.getFirstTokens(node)[1] || {};
if (specifier.type === 'ExportDefaultSpecifier') {
context.report({
node,
messageId: 'preferNamed',
loc,
});
}
else if (specifier.type === 'ExportSpecifier') {
context.report({
node,
messageId: 'noAliasDefault',
data: {
local: getValue(specifier.local),
},
loc,
});
}
}
},
};
},
});
//# sourceMappingURL=no-default-export.js.map