refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
---
|
||||
id: wiki-2026-0508-eslint-plugin-development
|
||||
title: ESLint Plugin Development
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [ESLint Custom Rules, ESLint Plugin Authoring]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [eslint, plugin, ast, linting]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: JavaScript/TypeScript
|
||||
framework: ESLint 9
|
||||
---
|
||||
|
||||
# ESLint Plugin Development
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 ESLint plugin은 AST visitor + RuleTester."**. ESLint 9 (2024-) Flat config 시대에는 plugin = `{rules, configs, processors}` object 의 export. 매 rule = `meta` (docs, fixable, schema) + `create(context)` returning visitor map (e.g., `CallExpression(node) { ... }`).
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 AST 기반
|
||||
- ESLint = ESTree spec (espree parser default; @typescript-eslint/parser for TS).
|
||||
- 매 rule visitor가 specific node type 방문 — `Identifier`, `CallExpression`, `JSXElement` 등.
|
||||
- `context.report({node, message, fix})` 으로 violation 보고.
|
||||
|
||||
### 매 Plugin shape (Flat config)
|
||||
- ESLint 9+ deprecated `.eslintrc` 형식 — 매 `eslint.config.js` flat config.
|
||||
- Plugin export = `{meta, rules, configs, processors}` — meta에 `name/version` 명시.
|
||||
|
||||
### 매 응용
|
||||
1. Internal style guide — 매 monorepo 의 component naming, import order.
|
||||
2. Framework rules — `eslint-plugin-react`, `eslint-plugin-vue` 처럼 framework-specific.
|
||||
3. Security lint — 매 dangerous API (eval, innerHTML) 금지.
|
||||
4. Migration codemod — 매 deprecated API 의 자동 fixer.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### 1. Minimal rule skeleton
|
||||
```javascript
|
||||
// rules/no-foo.js
|
||||
export default {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: { description: 'disallow Foo identifier', recommended: true },
|
||||
fixable: 'code',
|
||||
schema: [],
|
||||
messages: { unexpected: "'{{name}}' is not allowed." },
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
Identifier(node) {
|
||||
if (node.name === 'Foo') {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unexpected',
|
||||
data: { name: node.name },
|
||||
fix: (fixer) => fixer.replaceText(node, 'Bar'),
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### 2. Plugin entry (ESM, ESLint 9 flat)
|
||||
```javascript
|
||||
// index.js
|
||||
import noFoo from './rules/no-foo.js';
|
||||
|
||||
const plugin = {
|
||||
meta: { name: 'eslint-plugin-acme', version: '1.0.0' },
|
||||
rules: { 'no-foo': noFoo },
|
||||
};
|
||||
|
||||
plugin.configs = {
|
||||
recommended: {
|
||||
plugins: { acme: plugin },
|
||||
rules: { 'acme/no-foo': 'error' },
|
||||
},
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
```
|
||||
|
||||
### 3. Consumer flat config
|
||||
```javascript
|
||||
// eslint.config.js
|
||||
import acme from 'eslint-plugin-acme';
|
||||
|
||||
export default [
|
||||
acme.configs.recommended,
|
||||
{ rules: { 'acme/no-foo': ['error'] } },
|
||||
];
|
||||
```
|
||||
|
||||
### 4. RuleTester (built-in test)
|
||||
```javascript
|
||||
import { RuleTester } from 'eslint';
|
||||
import rule from '../rules/no-foo.js';
|
||||
|
||||
const tester = new RuleTester({
|
||||
languageOptions: { ecmaVersion: 2024, sourceType: 'module' },
|
||||
});
|
||||
|
||||
tester.run('no-foo', rule, {
|
||||
valid: ['const Bar = 1;'],
|
||||
invalid: [{
|
||||
code: 'const Foo = 1;',
|
||||
errors: [{ messageId: 'unexpected' }],
|
||||
output: 'const Bar = 1;',
|
||||
}],
|
||||
});
|
||||
```
|
||||
|
||||
### 5. TypeScript rule with @typescript-eslint
|
||||
```typescript
|
||||
import { ESLintUtils } from '@typescript-eslint/utils';
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator(
|
||||
(name) => `https://acme.dev/rules/${name}`,
|
||||
);
|
||||
|
||||
export default createRule({
|
||||
name: 'no-any',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: { description: 'disallow any' },
|
||||
schema: [],
|
||||
messages: { noAny: 'Avoid any; use unknown.' },
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
return {
|
||||
TSAnyKeyword(node) {
|
||||
context.report({ node, messageId: 'noAny' });
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### 6. Suggestions (non-auto fix)
|
||||
```javascript
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'considerRename',
|
||||
suggest: [{
|
||||
messageId: 'renameToBar',
|
||||
fix: (fixer) => fixer.replaceText(node, 'Bar'),
|
||||
}],
|
||||
});
|
||||
```
|
||||
|
||||
### 7. AST exploration (astexplorer.net)
|
||||
```javascript
|
||||
// Visitor pattern — leverage selector strings
|
||||
return {
|
||||
'CallExpression[callee.name="eval"]'(node) {
|
||||
context.report({ node, message: 'eval disallowed' });
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### 8. Scope / variable analysis
|
||||
```javascript
|
||||
create(context) {
|
||||
return {
|
||||
Identifier(node) {
|
||||
const scope = context.sourceCode.getScope(node);
|
||||
const variable = scope.references.find((r) => r.identifier === node);
|
||||
if (variable?.resolved?.defs[0]?.type === 'ImportBinding') {
|
||||
// imported identifier
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Codebase-specific 매 규칙 | Internal plugin (private npm). |
|
||||
| OSS 공유 | Publish `eslint-plugin-foo`. |
|
||||
| TS-only | `@typescript-eslint/utils` `RuleCreator`. |
|
||||
| 매 codemod 용 | jscodeshift / ts-morph (ESLint fix 보다 more powerful). |
|
||||
| 매 단순 ban API | `no-restricted-syntax` config — plugin 불필요. |
|
||||
|
||||
**기본값**: 매 ESLint 9 flat config + `@typescript-eslint/utils` RuleCreator.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[ESLint]] · [[AST]]
|
||||
- 변형: [[Biome]]
|
||||
- Adjacent: [[Prettier]] · [[TypeScript]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: AST visitor 작성, RuleTester case 생성, 매 selector string 의 작성.
|
||||
**언제 X**: 매 cross-file 분석 (ESLint = single-file) — 매 ts-morph / lsif 사용.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Regex on source**: 매 source string regex 의 X — 매 AST 사용.
|
||||
- **No tests**: 매 RuleTester 없는 rule 의 X — false positive 의 즉시 발생.
|
||||
- **Auto-fix without safety**: 매 fix가 매 semantics 변경 시 `suggest` 사용.
|
||||
- **`.eslintrc` in 2026**: 매 flat config 으로 migrate.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (ESLint 9 docs, eslint.org/docs/latest/extend).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — ESLint 9 flat config plugin authoring 패턴 |
|
||||
Reference in New Issue
Block a user