no-restricted-exports
禁止在导出中指定名称
在项目中,出于各种原因,某些名称可能不允许用作导出名称。
规则详情
此规则不允许将指定名称用作导出名称。
选项
默认情况下,此规则不允许任何名称。只有您在配置中指定的名称才会被禁止。
此规则有一个对象选项:
- l81LM1xDjtL6lBuzzK9i6VXwKE21gv1CKlnXJ1Qx2noxg2NpImLytf2XrApdC40SiNvaghZD8k1eSMeZpXv4Yv7RAR2zq775khFOEVqJSjVaTsTrNKlja0IgQpRNQw4JKjg7C9ZUgE8/rUgfD2Rs0bhrGoztUwDcax28DolEKA1icM74HXCN5520BFFSm7V+QQOO/Q6nud0H+yr/gGiSKLK9UhwQ/wzFiFnEbkaFoYTQ30g44cGpicKhmeSKa7c7b7xBHz3osSI8d3LoyW1s87ySbu//N7CGZT/VBLyByBdE8xhnPuItMvsZH6jtD5wcztmp1z9BEFFhnpaZJ3sw3f6GlZfeqyXn1DXgYetWQVi5GOZvspft782nplsPw0PU8OBOhtWa31iUpTgGO+g7KDHNXOpuaDg8BunLBZ1pQ/J+NDCUnoJr14B2rf7J65kpFPerqT98FOTMkwozenERjGSt+B9LFdmOHM567Hefhdv09gnoKEpCPAd9tOL1QAYk7qqRzJKXcyvPcWs3cUzO9uRjjtgDKRjX1wWstyInb4IsXEBCawvNeCZn8hCg+rVuZUsLsoa23Fyy+0S6sCwqCZEpniUWaa2PzI9Sel7a9gfnYo/YV28uyTseuuuOdugNnTWwTzEt7SOmmHm84NwXwODyGbvtt7R2SPb6MSEcUU8TO/YGbZRbpCGkyhqyXWFeGYDYQTg+ZqWhX/NK9WCvrJR3ehIU5WcZV8L4Oihcc4yqzjOMuRya+ETrK4jUvciwtqhxKY0rtfjt+9uPwnY5DNjMMcGpU0woq1gWTa43SR5k2cHaV5E55HWGT2BmFE9LlsWBOOU+zhXEODTFpMyK+fa67uOwvApoD5BE3O0pZNxaK0B5n3cu4vE6PDXSYdGvAXfHFd+Se8f2Y5iAV31Oc8FhWFrNuzwokYtlBz5IG61OJnsuuRusmqEFPKPcPJXO0JTe8RHCokKdktCWQwQfnzxJqkE8UZ7FN/rxZ+ovLGMeomfO2boAhGYnHzXTk+Ey6vWOc6IYBv80w//5HIsGUlzykbSHt8qcYZ32jyL7g362WZRe0QFmlAh6oAT7Z73hrkUpSF1YiCtHEYl5UMNXLG7yW2tSJj+f0lCop9ncl2+hjlo2q5n0G9RsjWdZ0XE6IcqVMD2vzkzknxCqCejZlQ==
restrictedNamedExports
FgRj4TFOiRokFZn4G20I/S8yAJe0GY5yX9LzbI1ZkRpmdjWKmcuGtGepfpBV2UlMBaOKOdgyXdJOLks8PwDep8QNZnppqtO0OaPEoWn+FXg=
/*eslint no-restricted-exports: ["error", {
"restrictedNamedExports": ["foo", "bar", "Baz", "a", "b", "c", "d", "e", "👍"]
}]*/
export const foo = 1;
export function bar() {}
export class Baz {}
const a = {};
export { a };
function someFunction() {}
export { someFunction as b };
export { c } from "some_module";
export { "d" } from "some_module";
export { something as e } from "some_module";
export { "👍" } from "some_module";
FgRj4TFOiRokFZn4G20I/S8yAJe0GY5yX9LzbI1ZkRqRcFX382gVJfQnz072+zqJuf8Zh1ysyaN9glWi43HwvqH7WngNfFwxBW1Z3RXvvC8=
/*eslint no-restricted-exports: ["error", {
"restrictedNamedExports": ["foo", "bar", "Baz", "a", "b", "c", "d", "e", "👍"]
}]*/
export const quux = 1;
export function myFunction() {}
export class MyClass {}
const a = {};
export { a as myObject };
function someFunction() {}
export { someFunction };
export { c as someName } from "some_module";
export { "d" as " d " } from "some_module";
export { something } from "some_module";
export { "👍" as thumbsUp } from "some_module";
默认导出
ekQP7tX11gn70RdZQBVzOiiqMahYL2gTwV+lNLl3DRltdSL9jxTitf0Ms3444UUoBMtGuJlws+4/GixVdIuV94Fl2KG/rSeDLBUdXgJlDFjNq/QD/oze2KgjLlEiWkvz4GXKcbTWiBLWvXdBe/4XzjL4mprn6oXzz3rUNLNJl9qm1HiflSb0V0ikXtjqYfuW1BbG8qhtVoQQUI+LbDRfLx/Hv6WJrwSOmPaheGH4vRCFEksjhIJm+tghb7g5Ildux6wKkpWDG/ayA2drgTeRoEpS90+bRSJLtydFWakE0HE=
FgRj4TFOiRokFZn4G20I/egYWksjSvmvOvKkhIaozfmWMNKWE90/El49zXaKZlKCBzVWDuCescJ0V8Oruy604iOS7KFyOD9RijQ1YbZezvdsiY60CeBFKzAzwchQ0NLm
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default"] }]*/
function foo() {}
export { foo as default };
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default"] }]*/
export { default } from "some_module";
FgRj4TFOiRokFZn4G20I/egYWksjSvmvOvKkhIaozfmWMNKWE90/El49zXaKZlKCYC3YGgRdlSCSRTqeU0KxoA+SsWTG8TRyTM9I0qg0w/gOBQrkX4iPJAxxALAsx5br
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["default", "foo"] }]*/
export default function foo() {}
restrictDefaultExports
NQhNpT4LA+tpIkXrrzbX9M0QJ0KI8c+EhcWwIX8nt5H/gASoE4APbdH5Acn/scS7b2yhJRHniKZVwk/L+nNOTQ7whBxlVq0+aG1ZBlRaDXgcvEI3FYA2ngOqjpNN1pxTVGHIyzUzW9iKQNjKbUD3xqgLPRJpS9/5Gkcv99Cck9F1yWkelQojFcP3IalyTiGsWrRavIlfYVsvjYooejP2pkTVqz0cIdhzu7GHlJhR4FCAfQZ3sxc89AlhVJUjhRj8ZK26RfdVuZokB1QTOcAFqw==
direct
nUVu8EswmQDtHaPUoFuUPx+b7t18Wa1PeQ8WP5/eunURLU4botNOQw3g7QtFGRQEI45QKHvNCJlnDAlJfmkzrKTJ6zl/wAuhiJLXRS6FvJlLpqKD/01A+43mRozHqvQ5
/*eslint no-restricted-exports: ["error", { "restrictDefaultExports": { "direct": true } }]*/
export default foo;
export default 42;
export default function foo() {}
named
nUVu8EswmQDtHaPUoFuUPx+b7t18Wa1PeQ8WP5/eunXrjzPBSAPTyeEJyRP0INu6sBEvfJJAGe7Bc+/Zcq/fZca1MTPgrAO1S7T/0iyEwbwjW1rK1hYrlyUM9uGyy8la
/*eslint no-restricted-exports: ["error", { "restrictDefaultExports": { "named": true } }]*/
const foo = 123;
export { foo as default };
defaultFrom
nUVu8EswmQDtHaPUoFuUPx+b7t18Wa1PeQ8WP5/eunXvewVUiJJW8wlu4CfM6G6QVTZQpHlVRgCCSQewTHh5vGfMu9S2dtYlpsgSbHwqPD6oaieY7meNRI+qRJ+Uzy+S
/*eslint no-restricted-exports: ["error", { "restrictDefaultExports": { "defaultFrom": true } }]*/
export { default } from 'foo';
export { default as default } from 'foo';
namedFrom
nUVu8EswmQDtHaPUoFuUPx+b7t18Wa1PeQ8WP5/eunUuVviDGieLHI+Dqe0DyX2LARQmhDPfJyMm9Kyloz+lDwSzO4dyRz6epfG4/kiuTF7mSG3TFvul5CXYVTFv3TS6
/*eslint no-restricted-exports: ["error", { "restrictDefaultExports": { "namedFrom": true } }]*/
export { foo as default } from 'foo';
namespaceFrom
nUVu8EswmQDtHaPUoFuUPx+b7t18Wa1PeQ8WP5/eunV1N7QvZqNKxVUWzHm0VMl8KtrxCMcvkZjULpdaIzOTj72gjFcElegqzPYSy51XGR1he/HpCQfbB0AskDOdfCNR
/*eslint no-restricted-exports: ["error", { "restrictDefaultExports": { "namespaceFrom": true } }]*/
export * as default from 'foo';
已知限制
hio0/LjoaubtsN8Ed133b9sWnp6VE4LDXCIKNncEZAAhVvFQ4kWTICSHWeI+d2JVkbE7b15xCUWPXBnyP/tS/fhcosn38D1f+grYqH+rVNkJZipCffp8+H23hDnbeu/09I7Xm76fuGssklEoTJY71aWNzKz9/9cXK8pW9re7X6yO9cXKfWUJrlwuucOKfKzZW5JQKHJoi6gkg2sHMdgDtH5mdM+Vv7Qw69afnsiei/a8VSEBl48Qhrjseh34aP04MNIu2l2axXpe1Ghv27qa5JOP2/ovjTXJk8H/8a5eTw8=
//----- some_module.js -----
export function foo() {}
//----- my_module.js -----
/*eslint no-restricted-exports: ["error", { "restrictedNamedExports": ["foo"] }]*/
export * from "some_module"; // allowed, although this declaration exports "foo" from my_module