This package eslint-plugin-export-restrict
is a custom plugin using ESLint for controlling export declarations from files.
It will be help to manage export declarations for private functions, classes, and variables in source code to manage developing.
In TypeScript and JavaScript, when declarers is defined in a file, it is not possible to manage strictly as a private functions, classes, and variables.
Using eslint-plugin-export-restrict
, you can protect by writing @private
as a comment like JSDoc and TSDoc, and solve those problems.
- npm
npm i -D eslint-plugin-export-restrict
- pnpm
pnpm i -D eslint-plugin-export-restrict
Depending on how you configure ESLint, use either Flat Config or eslintrc to configure eslint-plugin-export-restrict.
import exportRestrictPlugin from "eslint-plugin-export-restrict";
// const exportRestrictPlugin = require("eslint-plugin-export-restrict");
export default [
// other settings...
{
plugins: {
"export-restrict": exportRestrictPlugin,
},
rules: {
"export-restrict/no-export-private-declare": ["error"],
},
},
];
{
"plugins": [
"export-restrict",
],
"rules": {
"export-restrict/no-export-private-declare": ["error"],
}
}
// --------- good ---------
/** @private */
function func1() {}
/** @private */
function func2() {}
// --------- bad ----------
/** @private */
function func1() {}
/** @private */
export function func2() {}
export {
func1
}
Welcome
MIT