]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-restricted-exports.js
5b5c7d9bffb99c2d8cb1e242f9c22d69d17d8294
2 * @fileoverview Rule to disallow specified names in exports
3 * @author Milos Djermanovic
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
17 description
: "disallow specified names in exports",
18 category
: "ECMAScript 6",
20 url
: "https://eslint.org/docs/rules/no-restricted-exports"
26 restrictedNamedExports
: {
34 additionalProperties
: false
38 restrictedNamed
: "'{{name}}' is restricted from being used as an exported name."
44 const restrictedNames
= new Set(context
.options
[0] && context
.options
[0].restrictedNamedExports
);
47 * Checks and reports given exported identifier.
48 * @param {ASTNode} node exported `Identifer` node to check.
51 function checkExportedName(node
) {
52 const name
= node
.name
;
54 if (restrictedNames
.has(name
)) {
57 messageId
: "restrictedNamed",
64 ExportNamedDeclaration(node
) {
65 const declaration
= node
.declaration
;
68 if (declaration
.type
=== "FunctionDeclaration" || declaration
.type
=== "ClassDeclaration") {
69 checkExportedName(declaration
.id
);
70 } else if (declaration
.type
=== "VariableDeclaration") {
71 context
.getDeclaredVariables(declaration
)
72 .map(v
=> v
.defs
.find(d
=> d
.parent
=== declaration
))
73 .map(d
=> d
.name
) // Identifier nodes
74 .forEach(checkExportedName
);
79 .forEach(checkExportedName
);