ESLint plugin to enforce the access of specific return types.
- ESLint 8.40 or later (tested with ESLint 10)
@typescript-eslint/parserwith type information enabled (typed linting)
This plugin has no runtime dependencies.
npm install --save-dev eslint-plugin-return-type
# or
pnpm add --save-dev eslint-plugin-return-typeenforce-accesstypeNames:string[]- Type names whose values must be accessed. Each entry is a regular expression that must match the whole type name.
import tsParser from "@typescript-eslint/parser";
import returnType from "eslint-plugin-return-type";
export default [
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tsParser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
"return-type": returnType,
},
rules: {
"return-type/enforce-access": ["error", { typeNames: ["SomeType", "\\w*Error"] }],
},
},
];{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["return-type"],
"rules": {
"return-type/enforce-access": ["error", { "typeNames": ["SomeType", "\\w*Error"] }]
}
}Requires pnpm (see packageManager in package.json). pnpm installs the Node.js version in devEngines.runtime and runs the scripts with it. Use pnpm instead of npm in this repository.
pnpm install
pnpm test # Vitest
pnpm build # Compile to dist/
pnpm fmt # Format with oxfmt
pnpm fmt:checkThe Publish workflow publishes to npm with pnpm publish --provenance and trusted publishing.
- It runs on the 15th of every month (patch release), or manually from the Actions tab with
patch,minor, ormajor. - The job runs in the
npmenvironment and waits for approval before publishing. - It bumps the version, publishes the package, pushes the version commit and tag, and creates a GitHub release.
MIT