eslint-plugin-valkyriecoms/README.md

76 lines
1.4 KiB
Markdown
Raw Normal View History

2024-10-02 05:12:48 +00:00
# @valkyriecoms/eslint-plugin
2024-10-01 02:44:33 +00:00
2024-10-02 05:12:48 +00:00
`@valkyriecoms/eslint-plugin` is an ESLint plugin designed for Valkyriecoms developers. This plugin helps you write code that adheres to the coding style and best practices of the Valkyriecoms project.
## Installation
First, install the plugin using npm.
```bash
2024-10-02 11:06:16 +00:00
npm install --save-dev eslint @valkyriecoms/eslint-plugin @typescript-eslint/parser
2024-10-02 05:12:48 +00:00
```
## Usage
2024-10-02 11:06:16 +00:00
Create `eslint.config.js` file and write as follows
2024-10-02 05:12:48 +00:00
2024-10-02 11:06:16 +00:00
```javascript:eslint.config.js
import pluginValkyriecoms from '@valkyriecoms/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
export default [
...pluginValkyriecoms.configs['recommended'],
{
files: ['**/*.js', '**/*.jsx'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
parser: tsParser,
project: ['./tsconfig.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},
},
2024-10-02 05:12:48 +00:00
},
2024-10-02 11:06:16 +00:00
];
2024-10-02 05:12:48 +00:00
```
In tsconfig, strictNullChecks must be true.
```json:tsconfig.json
{
2024-10-02 11:06:16 +00:00
"compilerOptions": {
// ...
"strictNullChecks": true,
// ...
},
2024-10-02 05:12:48 +00:00
}
```
Add the eslint task to `package.json`
```json:package.json
{
2024-10-02 11:06:16 +00:00
"scripts": {
"eslint": "eslint './**/*.{js,jsx,ts,tsx}'"
},
2024-10-02 05:12:48 +00:00
}
```
Run the task
```
npm run eslint
```
## License
MIT License