mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
feat(monorepo): migrate vue packages and apply oxlint refactors
This commit is contained in:
21
configs/oxlint/rules/README.md
Normal file
21
configs/oxlint/rules/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Rules Reference
|
||||
|
||||
Документация по preset-ам `@robonen/oxlint`: что включает каждый preset и какие правила чаще всего влияют на код.
|
||||
|
||||
## Presets
|
||||
|
||||
- [base](./base.md)
|
||||
- [typescript](./typescript.md)
|
||||
- [vue](./vue.md)
|
||||
- [vitest](./vitest.md)
|
||||
- [imports](./imports.md)
|
||||
- [node](./node.md)
|
||||
- [stylistic](./stylistic.md)
|
||||
|
||||
## Как читать
|
||||
|
||||
- `Purpose` — зачем preset подключать.
|
||||
- `Key Rules` — ключевые правила из preset-а (не полный dump).
|
||||
- `Examples` — минимальные `good/bad` примеры.
|
||||
|
||||
Для точного источника правил см. файлы в `configs/oxlint/src/presets/*.ts`.
|
||||
34
configs/oxlint/rules/base.md
Normal file
34
configs/oxlint/rules/base.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# base preset
|
||||
|
||||
## Purpose
|
||||
|
||||
Базовый quality-профиль для JS/TS-проектов: корректность, анти-паттерны, безопасные дефолты.
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `eslint/eqeqeq`: запрещает `==`, требует `===`.
|
||||
- `eslint/no-unused-vars`: запрещает неиспользуемые переменные (кроме `_name`).
|
||||
- `eslint/no-eval`, `eslint/no-var`, `eslint/prefer-const`.
|
||||
- `unicorn/prefer-node-protocol`: требует `node:` для built-in модулей.
|
||||
- `unicorn/no-thenable`: запрещает thenable-объекты.
|
||||
- `oxc/*` correctness правила (`bad-comparison-sequence`, `missing-throw` и др.).
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
// ✅ Good
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
const id = 42;
|
||||
if (id === 42) {
|
||||
throw new Error('unexpected');
|
||||
}
|
||||
|
||||
// ❌ Bad
|
||||
import { readFile } from 'fs/promises';
|
||||
|
||||
var id = 42;
|
||||
if (id == '42') {
|
||||
throw 'unexpected';
|
||||
}
|
||||
```
|
||||
27
configs/oxlint/rules/imports.md
Normal file
27
configs/oxlint/rules/imports.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# imports preset
|
||||
|
||||
## Purpose
|
||||
|
||||
Чистые границы модулей и предсказуемые импорты.
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `import/no-duplicates`.
|
||||
- `import/no-self-import`.
|
||||
- `import/no-cycle` (warn).
|
||||
- `import/no-mutable-exports`.
|
||||
- `import/consistent-type-specifier-style`: `prefer-top-level`.
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
// ✅ Good
|
||||
import type { User } from './types';
|
||||
import { getUser } from './service';
|
||||
|
||||
// ❌ Bad
|
||||
import { getUser } from './service';
|
||||
import { getUser as getUser2 } from './service';
|
||||
|
||||
export let state = 0;
|
||||
```
|
||||
22
configs/oxlint/rules/node.md
Normal file
22
configs/oxlint/rules/node.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# node preset
|
||||
|
||||
## Purpose
|
||||
|
||||
Node.js-правила и окружение `env.node = true`.
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `node/no-exports-assign`: запрещает перезапись `exports`.
|
||||
- `node/no-new-require`: запрещает `new require(...)`.
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
// ✅ Good
|
||||
module.exports = { run };
|
||||
const mod = require('./mod');
|
||||
|
||||
// ❌ Bad
|
||||
exports = { run };
|
||||
const bad = new require('./mod');
|
||||
```
|
||||
51
configs/oxlint/rules/stylistic.md
Normal file
51
configs/oxlint/rules/stylistic.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# stylistic preset
|
||||
|
||||
## Purpose
|
||||
|
||||
Форматирование через `@stylistic/eslint-plugin` (отступы, пробелы, скобки, переносы, TS/JSX-стиль).
|
||||
|
||||
## Defaults
|
||||
|
||||
- `indent: 2`
|
||||
- `quotes: single`
|
||||
- `semi: always`
|
||||
- `braceStyle: stroustrup`
|
||||
- `commaDangle: always-multiline`
|
||||
- `arrowParens: as-needed`
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `@stylistic/indent`, `@stylistic/no-tabs`.
|
||||
- `@stylistic/quotes`, `@stylistic/semi`.
|
||||
- `@stylistic/object-curly-spacing`, `@stylistic/comma-spacing`.
|
||||
- `@stylistic/arrow-spacing`, `@stylistic/space-before-function-paren`.
|
||||
- `@stylistic/max-statements-per-line`.
|
||||
- `@stylistic/no-mixed-operators`.
|
||||
- `@stylistic/member-delimiter-style` (TS).
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
// ✅ Good
|
||||
type User = {
|
||||
id: string;
|
||||
role: 'admin' | 'user';
|
||||
};
|
||||
|
||||
const value = condition
|
||||
? 'yes'
|
||||
: 'no';
|
||||
|
||||
const sum = (a: number, b: number) => a + b;
|
||||
|
||||
// ❌ Bad
|
||||
type User = {
|
||||
id: string
|
||||
role: 'admin' | 'user'
|
||||
}
|
||||
|
||||
const value = condition ? 'yes' : 'no'; const x = 1;
|
||||
const sum=(a:number,b:number)=>{ return a+b };
|
||||
```
|
||||
|
||||
Полный список правил и их настройки см. в `src/presets/stylistic.ts`.
|
||||
33
configs/oxlint/rules/typescript.md
Normal file
33
configs/oxlint/rules/typescript.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# typescript preset
|
||||
|
||||
## Purpose
|
||||
|
||||
TypeScript-правила для `.ts/.tsx/.mts/.cts` через `overrides`.
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `typescript/consistent-type-imports`: выносит типы в `import type`.
|
||||
- `typescript/no-import-type-side-effects`: запрещает сайд-эффекты в type import.
|
||||
- `typescript/prefer-as-const`.
|
||||
- `typescript/no-namespace`, `typescript/triple-slash-reference`.
|
||||
- `typescript/no-wrapper-object-types`: запрещает `String`, `Number`, `Boolean`.
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
// ✅ Good
|
||||
import type { User } from './types';
|
||||
|
||||
const status = 'ok' as const;
|
||||
interface Payload {
|
||||
value: string;
|
||||
}
|
||||
|
||||
// ❌ Bad
|
||||
import { User } from './types';
|
||||
|
||||
type Boxed = String;
|
||||
namespace Legacy {
|
||||
export const x = 1;
|
||||
}
|
||||
```
|
||||
34
configs/oxlint/rules/vitest.md
Normal file
34
configs/oxlint/rules/vitest.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# vitest preset
|
||||
|
||||
## Purpose
|
||||
|
||||
Правила для тестов (`*.test.*`, `*.spec.*`, `test/**`, `__tests__/**`).
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `vitest/no-conditional-tests`.
|
||||
- `vitest/no-import-node-test`.
|
||||
- `vitest/prefer-to-be-truthy`, `vitest/prefer-to-be-falsy`.
|
||||
- `vitest/prefer-to-have-length`.
|
||||
- Relaxations: `eslint/no-unused-vars` и `typescript/no-explicit-any` выключены для тестов.
|
||||
|
||||
## Examples
|
||||
|
||||
```ts
|
||||
// ✅ Good
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('list', () => {
|
||||
it('has items', () => {
|
||||
expect([1, 2, 3]).toHaveLength(3);
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
// ❌ Bad
|
||||
if (process.env.CI) {
|
||||
it('conditionally runs', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
}
|
||||
```
|
||||
30
configs/oxlint/rules/vue.md
Normal file
30
configs/oxlint/rules/vue.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# vue preset
|
||||
|
||||
## Purpose
|
||||
|
||||
Правила для Vue 3 с упором на Composition API и `<script setup>`.
|
||||
|
||||
## Key Rules
|
||||
|
||||
- `vue/no-export-in-script-setup`.
|
||||
- `vue/no-import-compiler-macros`.
|
||||
- `vue/define-props-declaration`: type-based.
|
||||
- `vue/define-emits-declaration`: type-based.
|
||||
- `vue/valid-define-props`, `vue/valid-define-emits`.
|
||||
- `vue/no-lifecycle-after-await`.
|
||||
|
||||
## Examples
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ id: string }>();
|
||||
const emit = defineEmits<{ change: [value: string] }>();
|
||||
</script>
|
||||
|
||||
<!-- ❌ Bad -->
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue';
|
||||
export const x = 1;
|
||||
const props = defineProps({ id: String });
|
||||
</script>
|
||||
```
|
||||
Reference in New Issue
Block a user