0.2.3-beta • Published 7 months ago

eslint-plugin-export-restrict v0.2.3-beta

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

eslint-plugin-export-restrict

About

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.

Motivation

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.

Installation

  • 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.

Flat Config (eslint.config.js)

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"],
    },
  },
];

eslintrc

{
  "plugins": [
    "export-restrict",
  ],
  "rules": {
    "export-restrict/no-export-private-declare": ["error"],
  }
}

Example

// --------- good ---------
/** @private */
function func1() {}

/** @private */
function func2() {}


// --------- bad ----------
/** @private */
function func1() {}

/** @private */
export function func2() {}

export {
  func1
}

Contributing

Welcome

License

MIT

0.2.3-beta

7 months ago

0.2.2-beta

7 months ago

0.2.1-beta

7 months ago

0.2.0-beta

7 months ago

0.1.1-beta

7 months ago

0.1.0-beta

7 months ago