2 title: no-restricted-exports
8 In a project, certain names may be disallowed from being used as exported names for various reasons.
12 This rule disallows specified names from being used as exported names.
16 By default, this rule doesn't disallow any names. Only the names you specify in the configuration will be disallowed.
18 This rule has an object option:
20 * `"restrictedNamedExports"` is an array of strings, where each string is a name to be restricted.
22 Examples of **incorrect** code for this rule:
27 /*eslint no-restricted-exports: ["error", {
28 "restrictedNamedExports": ["foo", "bar", "Baz", "a", "b", "c", "d", "e", "👍"]
33 export function bar() {}
40 function someFunction() {}
41 export { someFunction as b };
43 export { c } from "some_module";
45 export { "d" } from "some_module";
47 export { something as e } from "some_module";
49 export { "👍" } from "some_module";
54 Examples of **correct** code for this rule:
59 /*eslint no-restricted-exports: ["error", {
60 "restrictedNamedExports": ["foo", "bar", "Baz", "a", "b", "c", "d", "e", "👍"]
63 export const quux = 1;
65 export function myFunction() {}
67 export class MyClass {}
70 export { a as myObject };
72 function someFunction() {}
73 export { someFunction };
75 export { c as someName } from "some_module";
77 export { "d" as " d " } from "some_module";
79 export { something } from "some_module";
81 export { "👍" as thumbsUp } from "some_module";
88 By design, this rule doesn't disallow `export default` declarations. If you configure `"default"` as a restricted name, that restriction will apply only to named export declarations.
90 Examples of additional **incorrect** code for this rule:
95 /*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default"] }]*/
99 export { foo as default };
107 /*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default"] }]*/
109 export { default } from "some_module";
114 Examples of additional **correct** code for this rule:
119 /*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default", "foo"] }]*/
121 export default function foo() {}
128 This rule doesn't inspect the content of source modules in re-export declarations. In particular, if you are re-exporting everything from another module's export, that export may include a restricted name. This rule cannot detect such cases.
132 //----- some_module.js -----
133 export function foo() {}
135 //----- my_module.js -----
136 /*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["foo"] }]*/
138 export * from "some_module"; // allowed, although this declaration exports "foo" from my_module