Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dorayx/eslint-plugin-ts-export-naming-convention
ESLint plugin to enforce naming conventions for TypeScript exports
https://github.com/dorayx/eslint-plugin-ts-export-naming-convention
eslint eslint-plugin eslint-typescript interface naming-conventions type-alias typescript
Last synced: about 1 month ago
JSON representation
ESLint plugin to enforce naming conventions for TypeScript exports
- Host: GitHub
- URL: https://github.com/dorayx/eslint-plugin-ts-export-naming-convention
- Owner: dorayx
- License: mit
- Created: 2023-09-01T18:37:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-08T15:53:21.000Z (over 1 year ago)
- Last Synced: 2024-10-12T17:22:35.923Z (2 months ago)
- Topics: eslint, eslint-plugin, eslint-typescript, interface, naming-conventions, type-alias, typescript
- Language: TypeScript
- Homepage:
- Size: 1.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-ts-export-naming-convention
An ESLint plugin to enforce naming conventions for TypeScript exports.
## Getting Started
1. Install dependencies
- [typescript-eslint](https://typescript-eslint.io/getting-started/): enables ESLint and Prettier to support TypeScript
- eslint-plugin-ts-export-naming-conventions```bash
yarn add -D \
eslint \
typescript \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint-plugin-ts-export-naming-convention
```2. Add the plugin to your ESLint config
```js
// .eslintrc.cjs
module.exports = {
plugins: [
'plugin:@typescript-eslint/recommended', // <-- more configurations found on https://typescript-eslint.io/linting/configs#recommended-configurations
'plugin:ts-export-export-naming-convention/recommended', // <-- apply the plugin
],
parser: '@typescript-eslint/parser',
};
```## Rules
### Interfaces & Type Aliases
- Interfaces & type aliases should be in format of PascalCase
```ts
// ✅ PascalCase
export interface IProps {}
export type TProps = {};// ❌ camelCase
export interface iProps {}
export type tProps = {};
```- Exported interface should be prefixed with `I`
```ts
// ✅ `IProps` interface is exported
export interface IProps {}// ❌ `Props` interface is exported
export interface Props {}// ✅ `AnotherProps` interface is NOT exported
interface AnotherProps {}
```- Exported type alias should be prefixed with `T`
```ts
// ✅ `TProps` type alias is exported
export type TProps = {};// ❌ `Props` type alias is exported
export type Props = {};// ✅ `AnotherProps` type alias is NOT exported
type AnotherProps = {};
```