eslint-plugin-ai-rules 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -22
- package/dist/index.cjs +3 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,7 +21,6 @@ Flat-config only ESLint plugin that bundles useful rules for AI-generated code.
|
|
|
21
21
|
- Node `>=18` (`package.json` `engines`)
|
|
22
22
|
- ESLint `^8.57.0 || ^9.0.0` (peer) — flat config requires ESLint 9
|
|
23
23
|
- TypeScript `>=5.0.0` (peer)
|
|
24
|
-
- `jiti` if you use `eslint.config.ts` (ESLint loads TS config via `jiti`)
|
|
25
24
|
|
|
26
25
|
`@eslint/js`, `eslint-plugin-import-x`, `@stylistic/eslint-plugin`, `typescript-eslint`, `globals` are already `dependencies` — you don't need to install them.
|
|
27
26
|
|
|
@@ -41,21 +40,25 @@ pnpm add -D eslint-plugin-ai-rules eslint typescript
|
|
|
41
40
|
bun add -d eslint-plugin-ai-rules eslint typescript
|
|
42
41
|
```
|
|
43
42
|
|
|
44
|
-
> `jiti` is required only for `eslint.config.ts`. Install it as dev dep if you use TS config:
|
|
45
|
-
> ```bash
|
|
46
|
-
> npm i -D jiti
|
|
47
|
-
> ```
|
|
48
|
-
|
|
49
43
|
## Quick Start
|
|
50
44
|
|
|
51
|
-
### `eslint.config.ts` (recommended)
|
|
45
|
+
### `eslint.config.ts` (recommended) — you define `files`
|
|
46
|
+
|
|
47
|
+
`recommended` is file-agnostic (only `plugins` + `settings` + `rules`). Define `files` in your config:
|
|
52
48
|
|
|
53
49
|
```ts
|
|
54
50
|
import aiRules from 'eslint-plugin-ai-rules'
|
|
55
51
|
|
|
56
52
|
export default [
|
|
57
|
-
...aiRules.configs.recommended,
|
|
53
|
+
{ files: ['**/*.{ts,tsx}'], ...aiRules.configs.recommended[0] },
|
|
54
|
+
// or spread: ...aiRules.configs.recommended with your own files wrapper
|
|
58
55
|
]
|
|
56
|
+
|
|
57
|
+
// Alternative with defineConfig:
|
|
58
|
+
import { defineConfig } from 'eslint/config'
|
|
59
|
+
export default defineConfig([
|
|
60
|
+
{ files: ['**/*.{ts,tsx}'], extends: [aiRules.configs.recommended] },
|
|
61
|
+
])
|
|
59
62
|
```
|
|
60
63
|
|
|
61
64
|
### `eslint.config.js` / `eslint.config.mjs`
|
|
@@ -64,7 +67,7 @@ export default [
|
|
|
64
67
|
import aiRules from 'eslint-plugin-ai-rules'
|
|
65
68
|
|
|
66
69
|
export default [
|
|
67
|
-
...aiRules.configs.recommended,
|
|
70
|
+
{ files: ['**/*.{js,ts,tsx}'], ...aiRules.configs.recommended[0] },
|
|
68
71
|
]
|
|
69
72
|
```
|
|
70
73
|
|
|
@@ -75,7 +78,7 @@ import aiRules from 'eslint-plugin-ai-rules'
|
|
|
75
78
|
import { defineConfig } from 'eslint/config'
|
|
76
79
|
|
|
77
80
|
export default defineConfig([
|
|
78
|
-
...aiRules.configs.recommended,
|
|
81
|
+
{ files: ['**/*.{ts,tsx}'], ...aiRules.configs.recommended[0] },
|
|
79
82
|
{
|
|
80
83
|
// turn off filename check for tests or generated code
|
|
81
84
|
files: ['**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}', 'scripts/**/*'],
|
|
@@ -103,11 +106,10 @@ npx eslint --fix . # autofix for sort-imports / no-multiline-imports
|
|
|
103
106
|
|
|
104
107
|
### `recommended` preset
|
|
105
108
|
|
|
106
|
-
`src/configs/recommended.ts` exports `defineConfig([...])` with
|
|
109
|
+
`src/configs/recommended.ts` exports `defineConfig([...])` with **only** `plugins` + `settings` + `rules` (file-agnostic) — you define `files`/`ignores`/`languageOptions`:
|
|
107
110
|
|
|
108
|
-
- `globalIgnores(['dist', 'src/services/generated', 'scripts/types'])`
|
|
109
|
-
- `files: ['**/*.{ts,tsx}']` — `extends: [js.configs.recommended, tseslint.configs.recommended]`, `languageOptions.globals: globals.browser`, `import-x/resolver-next` with `extensions: ['.ts','.tsx','.d.ts','.js','.jsx']`
|
|
110
111
|
- `plugins: { '@stylistic': stylistic, 'import-x': importX, 'ai-rules': plugin }`
|
|
112
|
+
- `settings: { 'import-x/resolver-next': ... }` with `extensions: ['.ts','.tsx','.d.ts','.js','.jsx']`
|
|
111
113
|
- Rules (all `error` unless noted):
|
|
112
114
|
|
|
113
115
|
| Rule | Default | Notes |
|
|
@@ -121,9 +123,9 @@ npx eslint --fix . # autofix for sort-imports / no-multiline-imports
|
|
|
121
123
|
| `@stylistic/semi` | `['error','never']` | No semicolons |
|
|
122
124
|
| `@typescript-eslint/consistent-type-imports` | `['error',{prefer:'type-imports'}]` | |
|
|
123
125
|
| `@typescript-eslint/no-unused-vars` | `['error',{argsIgnorePattern:'^_',varsIgnorePattern:'^_'}]` | |
|
|
124
|
-
| `@typescript-eslint/naming-convention` | `['error', {interface:'PascalCase' prefix I}, {typeAlias:'PascalCase' prefix T}]` |
|
|
126
|
+
| `@typescript-eslint/naming-convention` | `['error', {interface:'PascalCase' prefix I}, {typeAlias:'PascalCase' prefix T}]` | Disable per-project for `**/*.d.ts` via your own override if needed |
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
`recommended` has no `files`/`ignores` — add them in your `eslint.config.*` (see Quick Start). This repo's `eslint.config.mjs` adds `globalIgnores`, `files: ['**/*.{ts,tsx}']` with `extends: [js.configs.recommended, tseslint.configs.recommended]` + `globals.browser` locally.
|
|
127
129
|
|
|
128
130
|
### Custom setup (without `recommended`)
|
|
129
131
|
|
|
@@ -233,11 +235,11 @@ Plugin itself uses `module: ESNext` + `moduleResolution: bundler` (`tsconfig.jso
|
|
|
233
235
|
|
|
234
236
|
## Troubleshooting
|
|
235
237
|
|
|
236
|
-
|
|
238
|
+
**Missing `dist` before lint (repo uses `eslint.config.mjs` → `dist`)**
|
|
237
239
|
```
|
|
238
|
-
Error:
|
|
240
|
+
Error: Cannot find module './dist/index.js'
|
|
239
241
|
```
|
|
240
|
-
Fix: `npm
|
|
242
|
+
Fix: `npm run build` first. This repo's `eslint.config.mjs` imports from `dist` (no `jiti`), so `prelint` runs `build` automatically (`package.json` `prelint`).
|
|
241
243
|
|
|
242
244
|
**File ignored because outside of base path**
|
|
243
245
|
You passed an absolute path outside the config's `basePath`. Run `npx eslint .` from project root or use `npx eslint --no-config-lookup -c ./eslint.config.js ./src/file.ts` with correct cwd.
|
|
@@ -279,7 +281,7 @@ eslint-ai-guard/ # package: eslint-plugin-ai-rules
|
|
|
279
281
|
│ ├── SortImports.ts # also exports getSortedContent
|
|
280
282
|
│ └── index.ts
|
|
281
283
|
├── eslint/ # deprecated original implementations
|
|
282
|
-
├── eslint.config.
|
|
284
|
+
├── eslint.config.mjs # dogfooding: ...aiRules.configs.recommended from dist
|
|
283
285
|
├── tsconfig.json # ESNext/bundler, no .js extensions
|
|
284
286
|
├── tsup.config.ts # entry src/index.ts, format cjs+esm, dts, splitting:false
|
|
285
287
|
├── package.json # type module, exports ., files [dist]
|
|
@@ -299,9 +301,8 @@ eslint-ai-guard/ # package: eslint-plugin-ai-rules
|
|
|
299
301
|
|
|
300
302
|
```bash
|
|
301
303
|
npm version patch|minor|major
|
|
302
|
-
npm
|
|
303
|
-
npm publish --access public
|
|
304
|
-
# prepublishOnly runs build automatically
|
|
304
|
+
npm publish --access public # prepublishOnly runs verify (typecheck+build+lint+pack)
|
|
305
|
+
# or manually: npm run verify && npm publish --access public
|
|
305
306
|
```
|
|
306
307
|
|
|
307
308
|
## Legacy
|
package/dist/index.cjs
CHANGED
|
@@ -41,11 +41,9 @@ module.exports = __toCommonJS(index_exports);
|
|
|
41
41
|
|
|
42
42
|
// src/configs/recommended.ts
|
|
43
43
|
var import_eslint_plugin_import_x = require("eslint-plugin-import-x");
|
|
44
|
-
var import_config = require("eslint/config");
|
|
45
44
|
var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
|
|
45
|
+
var import_config = require("eslint/config");
|
|
46
46
|
var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
|
|
47
|
-
var import_globals = __toESM(require("globals"), 1);
|
|
48
|
-
var import_js = __toESM(require("@eslint/js"), 1);
|
|
49
47
|
|
|
50
48
|
// src/rules/FilenamePascalCase.ts
|
|
51
49
|
var import_node_path = __toESM(require("path"), 1);
|
|
@@ -267,17 +265,12 @@ var plugin = {
|
|
|
267
265
|
|
|
268
266
|
// src/configs/recommended.ts
|
|
269
267
|
var recommended = (0, import_config.defineConfig)([
|
|
270
|
-
(0, import_config.globalIgnores)(["dist", "src/services/generated", "scripts/types"]),
|
|
271
268
|
{
|
|
272
|
-
files: ["**/*.{ts,tsx}"],
|
|
273
|
-
extends: [import_js.default.configs.recommended, import_typescript_eslint.default.configs.recommended],
|
|
274
|
-
languageOptions: {
|
|
275
|
-
globals: import_globals.default.browser
|
|
276
|
-
},
|
|
277
269
|
plugins: {
|
|
278
270
|
"@stylistic": import_eslint_plugin.default,
|
|
279
271
|
"import-x": import_eslint_plugin_import_x.importX,
|
|
280
|
-
"ai-rules": plugin
|
|
272
|
+
"ai-rules": plugin,
|
|
273
|
+
"@typescript-eslint": import_typescript_eslint.default.plugin
|
|
281
274
|
},
|
|
282
275
|
settings: {
|
|
283
276
|
"import-x/resolver-next": [
|
|
@@ -308,12 +301,6 @@ var recommended = (0, import_config.defineConfig)([
|
|
|
308
301
|
{ selector: "typeAlias", format: ["PascalCase"], prefix: ["T"] }
|
|
309
302
|
]
|
|
310
303
|
}
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
files: ["**/*.d.ts", "scripts/**/*"],
|
|
314
|
-
rules: {
|
|
315
|
-
"@typescript-eslint/naming-convention": "off"
|
|
316
|
-
}
|
|
317
304
|
}
|
|
318
305
|
]);
|
|
319
306
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/configs/recommended.ts","../src/rules/FilenamePascalCase.ts","../src/rules/NoMultilineImports.ts","../src/rules/SortImports.ts","../src/plugin.ts"],"sourcesContent":["import { recommended } from './configs/recommended'\nimport { plugin } from './plugin'\n\nexport * from './rules/index'\n\n\nconst aiGuardPlugin = {\n ...plugin,\n configs: {\n recommended,\n },\n}\n\nexport default aiGuardPlugin\nexport { plugin }\nexport { recommended }","import { importX, createNodeResolver } from 'eslint-plugin-import-x'\nimport { defineConfig, globalIgnores } from 'eslint/config'\nimport stylistic from '@stylistic/eslint-plugin'\nimport tseslint from 'typescript-eslint'\nimport globals from 'globals'\nimport js from '@eslint/js'\n\nimport { plugin } from '../plugin'\n\n\nexport const recommended = defineConfig([\n globalIgnores(['dist', 'src/services/generated', 'scripts/types']),\n {\n files: ['**/*.{ts,tsx}'],\n extends: [js.configs.recommended, tseslint.configs.recommended],\n languageOptions: {\n globals: globals.browser,\n },\n plugins: {\n '@stylistic': stylistic,\n 'import-x': importX,\n 'ai-rules': plugin,\n },\n settings: {\n 'import-x/resolver-next': [\n createNodeResolver({\n extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],\n }),\n ],\n },\n rules: {\n 'ai-rules/sort-imports': 'error',\n 'ai-rules/no-multiline-imports': 'error',\n 'ai-rules/filename-pascal-case': 'error',\n 'max-len': 'off',\n 'import-x/no-duplicates': 'error',\n 'import-x/no-default-export': 'off',\n '@stylistic/semi': ['error', 'never'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports' },\n ],\n '@typescript-eslint/no-unused-vars': [\n 'error',\n { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },\n ],\n '@typescript-eslint/naming-convention': [\n 'error',\n { selector: 'interface', format: ['PascalCase'], prefix: ['I'] },\n { selector: 'typeAlias', format: ['PascalCase'], prefix: ['T'] },\n ],\n },\n },\n {\n files: ['**/*.d.ts', 'scripts/**/*'],\n rules: {\n '@typescript-eslint/naming-convention': 'off',\n },\n },\n])\n\nexport default recommended\n","import type { Rule } from 'eslint'\nimport path from 'node:path'\n\n\nexport const filenamePascalCase: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: { description: 'Enforce PascalCase for file names' },\n schema: [],\n messages: {\n invalid: 'File name \"{{basename}}\" must be in PascalCase. Rename to \"{{expected}}\".',\n },\n },\n create(context) {\n const physicalFilename =\n // eslint 9 flat config\n (context as unknown as { getPhysicalFilename?: () => string }).getPhysicalFilename?.() ??\n (context as unknown as { physicalFilename?: string }).physicalFilename ??\n context.filename ??\n ''\n\n const cwd =\n (context as unknown as { getCwd?: () => string }).getCwd?.() ?? process.cwd()\n\n // Normaliza para posix para comparar com src/ e scripts/\n const normalizedPhysical = physicalFilename.split(path.sep).join('/')\n const normalizedCwd = cwd.split(path.sep).join('/')\n\n const relativePath = normalizedPhysical.startsWith(normalizedCwd)\n ? normalizedPhysical.slice(normalizedCwd.length + 1)\n : normalizedPhysical\n\n if (!relativePath.startsWith('src/') && !relativePath.startsWith('scripts/')) return {}\n\n const basename = path.basename(relativePath)\n\n if (basename === 'index.ts' || basename === 'index.tsx' || basename === 'index.js' || basename === 'index.jsx') return {}\n if (basename.endsWith('.d.ts')) return {}\n if (basename.endsWith('.css')) return {}\n\n const ext = path.extname(basename) // .ts\n // Para casos como Component.spec.ts -> ext .ts, nameWithoutExt Component.spec - tratamos mantendo só base antes do primeiro ponto?\n // Mantemos compat com original: remove apenas última extensão .ts/.tsx/.js/.jsx\n const nameWithoutExt = basename.replace(/\\.(ts|tsx|js|jsx)$/, '')\n\n if (!/^[A-Z][a-zA-Z0-9]*$/.test(nameWithoutExt)) {\n const pascalCase = nameWithoutExt\n .split(/[-_]/)\n .map(part => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n\n // Preserva extensão original (ex: .tsx)\n const originalExt = basename.slice(nameWithoutExt.length) || ext\n const expected = `${pascalCase}${originalExt}`\n\n context.report({\n loc: { line: 1, column: 0 },\n messageId: 'invalid',\n data: { basename, expected },\n })\n }\n\n return {}\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const noMultilineImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n fixable: 'code',\n docs: {\n description: 'Disallow multiline imports',\n },\n schema: [],\n messages: {\n multilineImport: 'Imports must be written on a single line.',\n },\n },\n\n create(context) {\n const sourceCode = context.sourceCode\n\n return {\n ImportDeclaration(node) {\n const text = sourceCode.getText(node)\n\n if (!text.includes('\\n')) {\n return\n }\n\n context.report({\n node,\n messageId: 'multilineImport',\n\n fix(fixer) {\n const firstToken = sourceCode.getFirstToken(node)\n const lastToken = sourceCode.getLastToken(node)\n\n if (!firstToken || !lastToken) {\n return null\n }\n\n let importText = sourceCode.getText(node)\n\n importText = importText\n .replace(/\\s*\\{\\s*/g, ' { ')\n .replace(/\\s*\\}\\s*/g, ' } ')\n .replace(/\\s*,\\s*/g, ', ')\n .replace(/\\s+/g, ' ')\n .replace(/ \\{ /g, ' { ')\n .replace(/ \\} /g, ' } ')\n .replace(/\\s+from\\s+/g, ' from ')\n .trim()\n // Corrige espaços colapsados em torno de { e }\n .replace(/\\{ \\s+/g, '{ ')\n .replace(/\\s+ \\}/g, ' }')\n\n return fixer.replaceText(node, importText)\n },\n })\n },\n }\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const sortImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n docs: {\n description: 'Sort imports by group and line length descending, collapsing multiline imports',\n },\n fixable: 'code',\n schema: [],\n messages: {\n sortRequired: 'As importações devem estar ordenadas por grupo e tamanho da linha, ocupando uma única linha.',\n },\n },\n create(context) {\n return {\n Program(node) {\n const sourceCode = context.sourceCode\n const content = sourceCode.text\n\n const newContent = getSortedContent(content)\n\n if (newContent && newContent !== content) {\n context.report({\n node,\n messageId: 'sortRequired',\n fix(fixer) {\n return fixer.replaceText(node, newContent)\n },\n })\n }\n },\n }\n },\n}\n\n// ---------------------------------------------------------------------------\n// Tipos auxiliares\n// ---------------------------------------------------------------------------\ntype TImportItem = {\n line: string\n from: string\n}\n\n// ---------------------------------------------------------------------------\n// Lógica Core - exportada para teste e reutilização\n// ---------------------------------------------------------------------------\nexport function getSortedContent(content: string): string | null {\n const collapseMultiline = (match: string) => {\n return match\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/.*$/gm, '')\n .replace(/\\s+/g, ' ')\n }\n\n const normalizedContent = content\n .replace(/import\\s+([^'\";]+?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n // Apenas re-exports válidos: export { ... } from / export * from / export * as X from / export type { ... } from\n .replace(/export\\s+(?:type\\s+)?(?:\\{[^}]*\\}|\\*(?:\\s+as\\s+\\w+)?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n\n const lines: string[] = normalizedContent.split('\\n')\n\n const directiveLines: string[] = []\n const reactFirstLine: string[] = []\n const externalLines: TImportItem[] = []\n const internalLines: TImportItem[] = []\n const reExportLines: TImportItem[] = []\n const nonImportLines: string[] = []\n\n let inImportBlock = false\n let canAcceptDirectives = true\n\n for (let i = 0; i < lines.length; i++) {\n const trimmed = lines[i].trim()\n\n if (\n /^(function|const|let|var|class|interface|enum)\\b/.test(trimmed) ||\n (/^(type|export)\\b/.test(trimmed) && !/ from ['\"]/.test(trimmed) && !/^export\\s*\\{[^}]*\\}\\s*from/.test(trimmed) && !/^export\\s*\\*/.test(trimmed)) ||\n trimmed.startsWith('}')\n ) {\n canAcceptDirectives = false\n }\n\n if (inImportBlock && trimmed === '') continue\n\n if (canAcceptDirectives && /^['\"]use (client|server|strict)['\"];?$/.test(trimmed)) {\n directiveLines.push(lines[i])\n continue\n }\n\n const isReExport =\n /^export\\s+(type\\s+)?\\{[^}]*\\}\\s+from\\s+['\"]/.test(trimmed) ||\n /^export\\s+\\*(\\s+as\\s+\\w+)?\\s+from\\s+['\"]/.test(trimmed)\n\n if (isReExport) {\n const m = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n if (m) reExportLines.push({ line: lines[i], from: m[1] })\n inImportBlock = true\n canAcceptDirectives = false\n continue\n }\n\n const isImport = /^import\\s/.test(trimmed) || /^import\\{/.test(trimmed)\n\n if (isImport) {\n inImportBlock = true\n canAcceptDirectives = false\n\n const fromMatch = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n const seMatch = lines[i].match(/^import\\s+['\"]([^'\"]+)['\"]/)\n const from = fromMatch ? fromMatch[1] : seMatch ? seMatch[1] : null\n\n if (!from) {\n nonImportLines.push(lines[i])\n continue\n }\n\n const isTypeOnly = /^import\\s+type\\b/.test(trimmed)\n const isInternal = from.startsWith('.') || from.startsWith('@/')\n const isReactEntry = !isTypeOnly && (from === 'react' || from.startsWith('react/'))\n\n if (isReactEntry) {\n reactFirstLine.push(lines[i])\n } else if (isInternal) {\n internalLines.push({ line: lines[i], from })\n } else {\n externalLines.push({ line: lines[i], from })\n }\n continue\n }\n\n inImportBlock = false\n nonImportLines.push(lines[i])\n }\n\n if (reactFirstLine.length === 0 && externalLines.length === 0 && internalLines.length === 0 && reExportLines.length === 0) {\n return null\n }\n\n const byLengthDesc = (a: TImportItem, b: TImportItem) =>\n b.line.length !== a.line.length ? b.line.length - a.line.length : a.line.localeCompare(b.line)\n\n externalLines.sort(byLengthDesc)\n internalLines.sort(byLengthDesc)\n reExportLines.sort(byLengthDesc)\n\n const blocks: string[] = []\n\n if (directiveLines.length > 0) blocks.push(directiveLines.join('\\n'))\n\n const externalBlock = [...reactFirstLine, ...externalLines.map(i => i.line)]\n if (externalBlock.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(externalBlock.join('\\n'))\n }\n\n if (internalLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(internalLines.map(i => i.line).join('\\n'))\n }\n\n if (reExportLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(reExportLines.map(i => i.line).join('\\n'))\n }\n\n const rest = nonImportLines.join('\\n').replace(/^\\n+/, '')\n\n let newContent: string\n if (blocks.length > 0 && rest.length > 0) {\n newContent = blocks.join('\\n') + '\\n\\n\\n' + rest\n } else if (blocks.length > 0) {\n newContent = blocks.join('\\n') + '\\n'\n } else {\n newContent = rest\n }\n\n return newContent\n}\n","import { filenamePascalCase } from './rules/FilenamePascalCase'\nimport { noMultilineImports } from './rules/NoMultilineImports'\nimport { sortImports } from './rules/SortImports'\n\n\nexport const plugin = {\n meta: {\n name: 'eslint-plugin-ai-rules',\n version: '0.1.0',\n },\n rules: {\n 'filename-pascal-case': filenamePascalCase,\n 'no-multiline-imports': noMultilineImports,\n 'sort-imports': sortImports,\n },\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oCAA4C;AAC5C,oBAA4C;AAC5C,2BAAsB;AACtB,+BAAqB;AACrB,qBAAoB;AACpB,gBAAe;;;ACJf,uBAAiB;AAGV,IAAM,qBAAsC;AAAA,EACjD,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM,EAAE,aAAa,oCAAoC;AAAA,IACzD,QAAQ,CAAC;AAAA,IACT,UAAU;AAAA,MACR,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO,SAAS;AACd,UAAM;AAAA;AAAA,MAEH,QAA8D,sBAAsB,KACpF,QAAqD,oBACtD,QAAQ,YACR;AAAA;AAEF,UAAM,MACH,QAAiD,SAAS,KAAK,QAAQ,IAAI;AAG9E,UAAM,qBAAqB,iBAAiB,MAAM,iBAAAA,QAAK,GAAG,EAAE,KAAK,GAAG;AACpE,UAAM,gBAAgB,IAAI,MAAM,iBAAAA,QAAK,GAAG,EAAE,KAAK,GAAG;AAElD,UAAM,eAAe,mBAAmB,WAAW,aAAa,IAC5D,mBAAmB,MAAM,cAAc,SAAS,CAAC,IACjD;AAEJ,QAAI,CAAC,aAAa,WAAW,MAAM,KAAK,CAAC,aAAa,WAAW,UAAU,EAAG,QAAO,CAAC;AAEtF,UAAM,WAAW,iBAAAA,QAAK,SAAS,YAAY;AAE3C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A,YACxB,kDAAmB;AAAA,UACjB,YAAY,CAAC,OAAO,QAAQ,SAAS,OAAO,MAAM;AAAA,QACpD,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA,OAAO;AAAA,MACL,yBAAyB;AAAA,MACzB,iCAAiC;AAAA,MACjC,iCAAiC;AAAA,MACjC,WAAW;AAAA,MACX,0BAA0B;AAAA,MAC1B,8BAA8B;AAAA,MAC9B,mBAAmB,CAAC,SAAS,OAAO;AAAA,MACpC,8CAA8C;AAAA,QAC5C;AAAA,QACA,EAAE,QAAQ,eAAe;AAAA,MAC3B;AAAA,MACA,qCAAqC;AAAA,QACnC;AAAA,QACA,EAAE,mBAAmB,MAAM,mBAAmB,KAAK;AAAA,MACrD;AAAA,MACA,wCAAwC;AAAA,QACtC;AAAA,QACA,EAAE,UAAU,aAAa,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;AAAA,QAC/D,EAAE,UAAU,aAAa,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,OAAO,CAAC,aAAa,cAAc;AAAA,IACnC,OAAO;AAAA,MACL,wCAAwC;AAAA,IAC1C;AAAA,EACF;AACF,CAAC;;;ADrDD,IAAM,gBAAgB;AAAA,EACpB,GAAG;AAAA,EACH,SAAS;AAAA,IACP;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["path","js","tseslint","globals","stylistic"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/configs/recommended.ts","../src/rules/FilenamePascalCase.ts","../src/rules/NoMultilineImports.ts","../src/rules/SortImports.ts","../src/plugin.ts"],"sourcesContent":["import { recommended } from './configs/recommended'\nimport { plugin } from './plugin'\n\nexport * from './rules/index'\n\n\nconst aiGuardPlugin = {\n ...plugin,\n configs: {\n recommended,\n },\n}\n\nexport default aiGuardPlugin\nexport { plugin }\nexport { recommended }","import { createNodeResolver, importX } from 'eslint-plugin-import-x'\nimport stylistic from '@stylistic/eslint-plugin'\nimport { defineConfig } from 'eslint/config'\nimport tseslint from 'typescript-eslint'\n\nimport { plugin } from '../plugin'\n\n\nexport const recommended = defineConfig([\n {\n plugins: {\n '@stylistic': stylistic,\n 'import-x': importX,\n 'ai-rules': plugin,\n '@typescript-eslint': tseslint.plugin,\n },\n settings: {\n 'import-x/resolver-next': [\n createNodeResolver({\n extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],\n }),\n ],\n },\n rules: {\n 'ai-rules/sort-imports': 'error',\n 'ai-rules/no-multiline-imports': 'error',\n 'ai-rules/filename-pascal-case': 'error',\n 'max-len': 'off',\n 'import-x/no-duplicates': 'error',\n 'import-x/no-default-export': 'off',\n '@stylistic/semi': ['error', 'never'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports' },\n ],\n '@typescript-eslint/no-unused-vars': [\n 'error',\n { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },\n ],\n '@typescript-eslint/naming-convention': [\n 'error',\n { selector: 'interface', format: ['PascalCase'], prefix: ['I'] },\n { selector: 'typeAlias', format: ['PascalCase'], prefix: ['T'] },\n ],\n },\n },\n])\n\nexport default recommended\n","import type { Rule } from 'eslint'\nimport path from 'node:path'\n\n\nexport const filenamePascalCase: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: { description: 'Enforce PascalCase for file names' },\n schema: [],\n messages: {\n invalid: 'File name \"{{basename}}\" must be in PascalCase. Rename to \"{{expected}}\".',\n },\n },\n create(context) {\n const physicalFilename =\n // eslint 9 flat config\n (context as unknown as { getPhysicalFilename?: () => string }).getPhysicalFilename?.() ??\n (context as unknown as { physicalFilename?: string }).physicalFilename ??\n context.filename ??\n ''\n\n const cwd =\n (context as unknown as { getCwd?: () => string }).getCwd?.() ?? process.cwd()\n\n // Normaliza para posix para comparar com src/ e scripts/\n const normalizedPhysical = physicalFilename.split(path.sep).join('/')\n const normalizedCwd = cwd.split(path.sep).join('/')\n\n const relativePath = normalizedPhysical.startsWith(normalizedCwd)\n ? normalizedPhysical.slice(normalizedCwd.length + 1)\n : normalizedPhysical\n\n if (!relativePath.startsWith('src/') && !relativePath.startsWith('scripts/')) return {}\n\n const basename = path.basename(relativePath)\n\n if (basename === 'index.ts' || basename === 'index.tsx' || basename === 'index.js' || basename === 'index.jsx') return {}\n if (basename.endsWith('.d.ts')) return {}\n if (basename.endsWith('.css')) return {}\n\n const ext = path.extname(basename) // .ts\n // Para casos como Component.spec.ts -> ext .ts, nameWithoutExt Component.spec - tratamos mantendo só base antes do primeiro ponto?\n // Mantemos compat com original: remove apenas última extensão .ts/.tsx/.js/.jsx\n const nameWithoutExt = basename.replace(/\\.(ts|tsx|js|jsx)$/, '')\n\n if (!/^[A-Z][a-zA-Z0-9]*$/.test(nameWithoutExt)) {\n const pascalCase = nameWithoutExt\n .split(/[-_]/)\n .map(part => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n\n // Preserva extensão original (ex: .tsx)\n const originalExt = basename.slice(nameWithoutExt.length) || ext\n const expected = `${pascalCase}${originalExt}`\n\n context.report({\n loc: { line: 1, column: 0 },\n messageId: 'invalid',\n data: { basename, expected },\n })\n }\n\n return {}\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const noMultilineImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n fixable: 'code',\n docs: {\n description: 'Disallow multiline imports',\n },\n schema: [],\n messages: {\n multilineImport: 'Imports must be written on a single line.',\n },\n },\n\n create(context) {\n const sourceCode = context.sourceCode\n\n return {\n ImportDeclaration(node) {\n const text = sourceCode.getText(node)\n\n if (!text.includes('\\n')) {\n return\n }\n\n context.report({\n node,\n messageId: 'multilineImport',\n\n fix(fixer) {\n const firstToken = sourceCode.getFirstToken(node)\n const lastToken = sourceCode.getLastToken(node)\n\n if (!firstToken || !lastToken) {\n return null\n }\n\n let importText = sourceCode.getText(node)\n\n importText = importText\n .replace(/\\s*\\{\\s*/g, ' { ')\n .replace(/\\s*\\}\\s*/g, ' } ')\n .replace(/\\s*,\\s*/g, ', ')\n .replace(/\\s+/g, ' ')\n .replace(/ \\{ /g, ' { ')\n .replace(/ \\} /g, ' } ')\n .replace(/\\s+from\\s+/g, ' from ')\n .trim()\n // Corrige espaços colapsados em torno de { e }\n .replace(/\\{ \\s+/g, '{ ')\n .replace(/\\s+ \\}/g, ' }')\n\n return fixer.replaceText(node, importText)\n },\n })\n },\n }\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const sortImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n docs: {\n description: 'Sort imports by group and line length descending, collapsing multiline imports',\n },\n fixable: 'code',\n schema: [],\n messages: {\n sortRequired: 'As importações devem estar ordenadas por grupo e tamanho da linha, ocupando uma única linha.',\n },\n },\n create(context) {\n return {\n Program(node) {\n const sourceCode = context.sourceCode\n const content = sourceCode.text\n\n const newContent = getSortedContent(content)\n\n if (newContent && newContent !== content) {\n context.report({\n node,\n messageId: 'sortRequired',\n fix(fixer) {\n return fixer.replaceText(node, newContent)\n },\n })\n }\n },\n }\n },\n}\n\n// ---------------------------------------------------------------------------\n// Tipos auxiliares\n// ---------------------------------------------------------------------------\ntype TImportItem = {\n line: string\n from: string\n}\n\n// ---------------------------------------------------------------------------\n// Lógica Core - exportada para teste e reutilização\n// ---------------------------------------------------------------------------\nexport function getSortedContent(content: string): string | null {\n const collapseMultiline = (match: string) => {\n return match\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/.*$/gm, '')\n .replace(/\\s+/g, ' ')\n }\n\n const normalizedContent = content\n .replace(/import\\s+([^'\";]+?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n // Apenas re-exports válidos: export { ... } from / export * from / export * as X from / export type { ... } from\n .replace(/export\\s+(?:type\\s+)?(?:\\{[^}]*\\}|\\*(?:\\s+as\\s+\\w+)?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n\n const lines: string[] = normalizedContent.split('\\n')\n\n const directiveLines: string[] = []\n const reactFirstLine: string[] = []\n const externalLines: TImportItem[] = []\n const internalLines: TImportItem[] = []\n const reExportLines: TImportItem[] = []\n const nonImportLines: string[] = []\n\n let inImportBlock = false\n let canAcceptDirectives = true\n\n for (let i = 0; i < lines.length; i++) {\n const trimmed = lines[i].trim()\n\n if (\n /^(function|const|let|var|class|interface|enum)\\b/.test(trimmed) ||\n (/^(type|export)\\b/.test(trimmed) && !/ from ['\"]/.test(trimmed) && !/^export\\s*\\{[^}]*\\}\\s*from/.test(trimmed) && !/^export\\s*\\*/.test(trimmed)) ||\n trimmed.startsWith('}')\n ) {\n canAcceptDirectives = false\n }\n\n if (inImportBlock && trimmed === '') continue\n\n if (canAcceptDirectives && /^['\"]use (client|server|strict)['\"];?$/.test(trimmed)) {\n directiveLines.push(lines[i])\n continue\n }\n\n const isReExport =\n /^export\\s+(type\\s+)?\\{[^}]*\\}\\s+from\\s+['\"]/.test(trimmed) ||\n /^export\\s+\\*(\\s+as\\s+\\w+)?\\s+from\\s+['\"]/.test(trimmed)\n\n if (isReExport) {\n const m = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n if (m) reExportLines.push({ line: lines[i], from: m[1] })\n inImportBlock = true\n canAcceptDirectives = false\n continue\n }\n\n const isImport = /^import\\s/.test(trimmed) || /^import\\{/.test(trimmed)\n\n if (isImport) {\n inImportBlock = true\n canAcceptDirectives = false\n\n const fromMatch = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n const seMatch = lines[i].match(/^import\\s+['\"]([^'\"]+)['\"]/)\n const from = fromMatch ? fromMatch[1] : seMatch ? seMatch[1] : null\n\n if (!from) {\n nonImportLines.push(lines[i])\n continue\n }\n\n const isTypeOnly = /^import\\s+type\\b/.test(trimmed)\n const isInternal = from.startsWith('.') || from.startsWith('@/')\n const isReactEntry = !isTypeOnly && (from === 'react' || from.startsWith('react/'))\n\n if (isReactEntry) {\n reactFirstLine.push(lines[i])\n } else if (isInternal) {\n internalLines.push({ line: lines[i], from })\n } else {\n externalLines.push({ line: lines[i], from })\n }\n continue\n }\n\n inImportBlock = false\n nonImportLines.push(lines[i])\n }\n\n if (reactFirstLine.length === 0 && externalLines.length === 0 && internalLines.length === 0 && reExportLines.length === 0) {\n return null\n }\n\n const byLengthDesc = (a: TImportItem, b: TImportItem) =>\n b.line.length !== a.line.length ? b.line.length - a.line.length : a.line.localeCompare(b.line)\n\n externalLines.sort(byLengthDesc)\n internalLines.sort(byLengthDesc)\n reExportLines.sort(byLengthDesc)\n\n const blocks: string[] = []\n\n if (directiveLines.length > 0) blocks.push(directiveLines.join('\\n'))\n\n const externalBlock = [...reactFirstLine, ...externalLines.map(i => i.line)]\n if (externalBlock.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(externalBlock.join('\\n'))\n }\n\n if (internalLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(internalLines.map(i => i.line).join('\\n'))\n }\n\n if (reExportLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(reExportLines.map(i => i.line).join('\\n'))\n }\n\n const rest = nonImportLines.join('\\n').replace(/^\\n+/, '')\n\n let newContent: string\n if (blocks.length > 0 && rest.length > 0) {\n newContent = blocks.join('\\n') + '\\n\\n\\n' + rest\n } else if (blocks.length > 0) {\n newContent = blocks.join('\\n') + '\\n'\n } else {\n newContent = rest\n }\n\n return newContent\n}\n","import { filenamePascalCase } from './rules/FilenamePascalCase'\nimport { noMultilineImports } from './rules/NoMultilineImports'\nimport { sortImports } from './rules/SortImports'\n\n\nexport const plugin = {\n meta: {\n name: 'eslint-plugin-ai-rules',\n version: '0.1.0',\n },\n rules: {\n 'filename-pascal-case': filenamePascalCase,\n 'no-multiline-imports': noMultilineImports,\n 'sort-imports': sortImports,\n },\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;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;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ADxCD,IAAM,gBAAgB;AAAA,EACpB,GAAG;AAAA,EACH,SAAS;AAAA,IACP;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["path","stylistic","tseslint"]}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// src/configs/recommended.ts
|
|
2
|
-
import {
|
|
3
|
-
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import { createNodeResolver, importX } from "eslint-plugin-import-x";
|
|
4
3
|
import stylistic from "@stylistic/eslint-plugin";
|
|
4
|
+
import { defineConfig } from "eslint/config";
|
|
5
5
|
import tseslint from "typescript-eslint";
|
|
6
|
-
import globals from "globals";
|
|
7
|
-
import js from "@eslint/js";
|
|
8
6
|
|
|
9
7
|
// src/rules/FilenamePascalCase.ts
|
|
10
8
|
import path from "path";
|
|
@@ -226,17 +224,12 @@ var plugin = {
|
|
|
226
224
|
|
|
227
225
|
// src/configs/recommended.ts
|
|
228
226
|
var recommended = defineConfig([
|
|
229
|
-
globalIgnores(["dist", "src/services/generated", "scripts/types"]),
|
|
230
227
|
{
|
|
231
|
-
files: ["**/*.{ts,tsx}"],
|
|
232
|
-
extends: [js.configs.recommended, tseslint.configs.recommended],
|
|
233
|
-
languageOptions: {
|
|
234
|
-
globals: globals.browser
|
|
235
|
-
},
|
|
236
228
|
plugins: {
|
|
237
229
|
"@stylistic": stylistic,
|
|
238
230
|
"import-x": importX,
|
|
239
|
-
"ai-rules": plugin
|
|
231
|
+
"ai-rules": plugin,
|
|
232
|
+
"@typescript-eslint": tseslint.plugin
|
|
240
233
|
},
|
|
241
234
|
settings: {
|
|
242
235
|
"import-x/resolver-next": [
|
|
@@ -267,12 +260,6 @@ var recommended = defineConfig([
|
|
|
267
260
|
{ selector: "typeAlias", format: ["PascalCase"], prefix: ["T"] }
|
|
268
261
|
]
|
|
269
262
|
}
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
files: ["**/*.d.ts", "scripts/**/*"],
|
|
273
|
-
rules: {
|
|
274
|
-
"@typescript-eslint/naming-convention": "off"
|
|
275
|
-
}
|
|
276
263
|
}
|
|
277
264
|
]);
|
|
278
265
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/configs/recommended.ts","../src/rules/FilenamePascalCase.ts","../src/rules/NoMultilineImports.ts","../src/rules/SortImports.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["import { importX, createNodeResolver } from 'eslint-plugin-import-x'\nimport { defineConfig, globalIgnores } from 'eslint/config'\nimport stylistic from '@stylistic/eslint-plugin'\nimport tseslint from 'typescript-eslint'\nimport globals from 'globals'\nimport js from '@eslint/js'\n\nimport { plugin } from '../plugin'\n\n\nexport const recommended = defineConfig([\n globalIgnores(['dist', 'src/services/generated', 'scripts/types']),\n {\n files: ['**/*.{ts,tsx}'],\n extends: [js.configs.recommended, tseslint.configs.recommended],\n languageOptions: {\n globals: globals.browser,\n },\n plugins: {\n '@stylistic': stylistic,\n 'import-x': importX,\n 'ai-rules': plugin,\n },\n settings: {\n 'import-x/resolver-next': [\n createNodeResolver({\n extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],\n }),\n ],\n },\n rules: {\n 'ai-rules/sort-imports': 'error',\n 'ai-rules/no-multiline-imports': 'error',\n 'ai-rules/filename-pascal-case': 'error',\n 'max-len': 'off',\n 'import-x/no-duplicates': 'error',\n 'import-x/no-default-export': 'off',\n '@stylistic/semi': ['error', 'never'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports' },\n ],\n '@typescript-eslint/no-unused-vars': [\n 'error',\n { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },\n ],\n '@typescript-eslint/naming-convention': [\n 'error',\n { selector: 'interface', format: ['PascalCase'], prefix: ['I'] },\n { selector: 'typeAlias', format: ['PascalCase'], prefix: ['T'] },\n ],\n },\n },\n {\n files: ['**/*.d.ts', 'scripts/**/*'],\n rules: {\n '@typescript-eslint/naming-convention': 'off',\n },\n },\n])\n\nexport default recommended\n","import type { Rule } from 'eslint'\nimport path from 'node:path'\n\n\nexport const filenamePascalCase: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: { description: 'Enforce PascalCase for file names' },\n schema: [],\n messages: {\n invalid: 'File name \"{{basename}}\" must be in PascalCase. Rename to \"{{expected}}\".',\n },\n },\n create(context) {\n const physicalFilename =\n // eslint 9 flat config\n (context as unknown as { getPhysicalFilename?: () => string }).getPhysicalFilename?.() ??\n (context as unknown as { physicalFilename?: string }).physicalFilename ??\n context.filename ??\n ''\n\n const cwd =\n (context as unknown as { getCwd?: () => string }).getCwd?.() ?? process.cwd()\n\n // Normaliza para posix para comparar com src/ e scripts/\n const normalizedPhysical = physicalFilename.split(path.sep).join('/')\n const normalizedCwd = cwd.split(path.sep).join('/')\n\n const relativePath = normalizedPhysical.startsWith(normalizedCwd)\n ? normalizedPhysical.slice(normalizedCwd.length + 1)\n : normalizedPhysical\n\n if (!relativePath.startsWith('src/') && !relativePath.startsWith('scripts/')) return {}\n\n const basename = path.basename(relativePath)\n\n if (basename === 'index.ts' || basename === 'index.tsx' || basename === 'index.js' || basename === 'index.jsx') return {}\n if (basename.endsWith('.d.ts')) return {}\n if (basename.endsWith('.css')) return {}\n\n const ext = path.extname(basename) // .ts\n // Para casos como Component.spec.ts -> ext .ts, nameWithoutExt Component.spec - tratamos mantendo só base antes do primeiro ponto?\n // Mantemos compat com original: remove apenas última extensão .ts/.tsx/.js/.jsx\n const nameWithoutExt = basename.replace(/\\.(ts|tsx|js|jsx)$/, '')\n\n if (!/^[A-Z][a-zA-Z0-9]*$/.test(nameWithoutExt)) {\n const pascalCase = nameWithoutExt\n .split(/[-_]/)\n .map(part => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n\n // Preserva extensão original (ex: .tsx)\n const originalExt = basename.slice(nameWithoutExt.length) || ext\n const expected = `${pascalCase}${originalExt}`\n\n context.report({\n loc: { line: 1, column: 0 },\n messageId: 'invalid',\n data: { basename, expected },\n })\n }\n\n return {}\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const noMultilineImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n fixable: 'code',\n docs: {\n description: 'Disallow multiline imports',\n },\n schema: [],\n messages: {\n multilineImport: 'Imports must be written on a single line.',\n },\n },\n\n create(context) {\n const sourceCode = context.sourceCode\n\n return {\n ImportDeclaration(node) {\n const text = sourceCode.getText(node)\n\n if (!text.includes('\\n')) {\n return\n }\n\n context.report({\n node,\n messageId: 'multilineImport',\n\n fix(fixer) {\n const firstToken = sourceCode.getFirstToken(node)\n const lastToken = sourceCode.getLastToken(node)\n\n if (!firstToken || !lastToken) {\n return null\n }\n\n let importText = sourceCode.getText(node)\n\n importText = importText\n .replace(/\\s*\\{\\s*/g, ' { ')\n .replace(/\\s*\\}\\s*/g, ' } ')\n .replace(/\\s*,\\s*/g, ', ')\n .replace(/\\s+/g, ' ')\n .replace(/ \\{ /g, ' { ')\n .replace(/ \\} /g, ' } ')\n .replace(/\\s+from\\s+/g, ' from ')\n .trim()\n // Corrige espaços colapsados em torno de { e }\n .replace(/\\{ \\s+/g, '{ ')\n .replace(/\\s+ \\}/g, ' }')\n\n return fixer.replaceText(node, importText)\n },\n })\n },\n }\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const sortImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n docs: {\n description: 'Sort imports by group and line length descending, collapsing multiline imports',\n },\n fixable: 'code',\n schema: [],\n messages: {\n sortRequired: 'As importações devem estar ordenadas por grupo e tamanho da linha, ocupando uma única linha.',\n },\n },\n create(context) {\n return {\n Program(node) {\n const sourceCode = context.sourceCode\n const content = sourceCode.text\n\n const newContent = getSortedContent(content)\n\n if (newContent && newContent !== content) {\n context.report({\n node,\n messageId: 'sortRequired',\n fix(fixer) {\n return fixer.replaceText(node, newContent)\n },\n })\n }\n },\n }\n },\n}\n\n// ---------------------------------------------------------------------------\n// Tipos auxiliares\n// ---------------------------------------------------------------------------\ntype TImportItem = {\n line: string\n from: string\n}\n\n// ---------------------------------------------------------------------------\n// Lógica Core - exportada para teste e reutilização\n// ---------------------------------------------------------------------------\nexport function getSortedContent(content: string): string | null {\n const collapseMultiline = (match: string) => {\n return match\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/.*$/gm, '')\n .replace(/\\s+/g, ' ')\n }\n\n const normalizedContent = content\n .replace(/import\\s+([^'\";]+?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n // Apenas re-exports válidos: export { ... } from / export * from / export * as X from / export type { ... } from\n .replace(/export\\s+(?:type\\s+)?(?:\\{[^}]*\\}|\\*(?:\\s+as\\s+\\w+)?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n\n const lines: string[] = normalizedContent.split('\\n')\n\n const directiveLines: string[] = []\n const reactFirstLine: string[] = []\n const externalLines: TImportItem[] = []\n const internalLines: TImportItem[] = []\n const reExportLines: TImportItem[] = []\n const nonImportLines: string[] = []\n\n let inImportBlock = false\n let canAcceptDirectives = true\n\n for (let i = 0; i < lines.length; i++) {\n const trimmed = lines[i].trim()\n\n if (\n /^(function|const|let|var|class|interface|enum)\\b/.test(trimmed) ||\n (/^(type|export)\\b/.test(trimmed) && !/ from ['\"]/.test(trimmed) && !/^export\\s*\\{[^}]*\\}\\s*from/.test(trimmed) && !/^export\\s*\\*/.test(trimmed)) ||\n trimmed.startsWith('}')\n ) {\n canAcceptDirectives = false\n }\n\n if (inImportBlock && trimmed === '') continue\n\n if (canAcceptDirectives && /^['\"]use (client|server|strict)['\"];?$/.test(trimmed)) {\n directiveLines.push(lines[i])\n continue\n }\n\n const isReExport =\n /^export\\s+(type\\s+)?\\{[^}]*\\}\\s+from\\s+['\"]/.test(trimmed) ||\n /^export\\s+\\*(\\s+as\\s+\\w+)?\\s+from\\s+['\"]/.test(trimmed)\n\n if (isReExport) {\n const m = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n if (m) reExportLines.push({ line: lines[i], from: m[1] })\n inImportBlock = true\n canAcceptDirectives = false\n continue\n }\n\n const isImport = /^import\\s/.test(trimmed) || /^import\\{/.test(trimmed)\n\n if (isImport) {\n inImportBlock = true\n canAcceptDirectives = false\n\n const fromMatch = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n const seMatch = lines[i].match(/^import\\s+['\"]([^'\"]+)['\"]/)\n const from = fromMatch ? fromMatch[1] : seMatch ? seMatch[1] : null\n\n if (!from) {\n nonImportLines.push(lines[i])\n continue\n }\n\n const isTypeOnly = /^import\\s+type\\b/.test(trimmed)\n const isInternal = from.startsWith('.') || from.startsWith('@/')\n const isReactEntry = !isTypeOnly && (from === 'react' || from.startsWith('react/'))\n\n if (isReactEntry) {\n reactFirstLine.push(lines[i])\n } else if (isInternal) {\n internalLines.push({ line: lines[i], from })\n } else {\n externalLines.push({ line: lines[i], from })\n }\n continue\n }\n\n inImportBlock = false\n nonImportLines.push(lines[i])\n }\n\n if (reactFirstLine.length === 0 && externalLines.length === 0 && internalLines.length === 0 && reExportLines.length === 0) {\n return null\n }\n\n const byLengthDesc = (a: TImportItem, b: TImportItem) =>\n b.line.length !== a.line.length ? b.line.length - a.line.length : a.line.localeCompare(b.line)\n\n externalLines.sort(byLengthDesc)\n internalLines.sort(byLengthDesc)\n reExportLines.sort(byLengthDesc)\n\n const blocks: string[] = []\n\n if (directiveLines.length > 0) blocks.push(directiveLines.join('\\n'))\n\n const externalBlock = [...reactFirstLine, ...externalLines.map(i => i.line)]\n if (externalBlock.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(externalBlock.join('\\n'))\n }\n\n if (internalLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(internalLines.map(i => i.line).join('\\n'))\n }\n\n if (reExportLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(reExportLines.map(i => i.line).join('\\n'))\n }\n\n const rest = nonImportLines.join('\\n').replace(/^\\n+/, '')\n\n let newContent: string\n if (blocks.length > 0 && rest.length > 0) {\n newContent = blocks.join('\\n') + '\\n\\n\\n' + rest\n } else if (blocks.length > 0) {\n newContent = blocks.join('\\n') + '\\n'\n } else {\n newContent = rest\n }\n\n return newContent\n}\n","import { filenamePascalCase } from './rules/FilenamePascalCase'\nimport { noMultilineImports } from './rules/NoMultilineImports'\nimport { sortImports } from './rules/SortImports'\n\n\nexport const plugin = {\n meta: {\n name: 'eslint-plugin-ai-rules',\n version: '0.1.0',\n },\n rules: {\n 'filename-pascal-case': filenamePascalCase,\n 'no-multiline-imports': noMultilineImports,\n 'sort-imports': sortImports,\n },\n} as const\n","import { recommended } from './configs/recommended'\nimport { plugin } from './plugin'\n\nexport * from './rules/index'\n\n\nconst aiGuardPlugin = {\n ...plugin,\n configs: {\n recommended,\n },\n}\n\nexport default aiGuardPlugin\nexport { plugin }\nexport { recommended }"],"mappings":";AAAA,SAAS,SAAS,0BAA0B;AAC5C,SAAS,cAAc,qBAAqB;AAC5C,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,OAAO,aAAa;AACpB,OAAO,QAAQ;;;ACJf,OAAO,UAAU;AAGV,IAAM,qBAAsC;AAAA,EACjD,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM,EAAE,aAAa,oCAAoC;AAAA,IACzD,QAAQ,CAAC;AAAA,IACT,UAAU;AAAA,MACR,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,OAAO,SAAS;AACd,UAAM;AAAA;AAAA,MAEH,QAA8D,sBAAsB,KACpF,QAAqD,oBACtD,QAAQ,YACR;AAAA;AAEF,UAAM,MACH,QAAiD,SAAS,KAAK,QAAQ,IAAI;AAG9E,UAAM,qBAAqB,iBAAiB,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACpE,UAAM,gBAAgB,IAAI,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AAElD,UAAM,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B;AAAA,MACf,SAAS,QAAQ;AAAA,IACnB;AAAA,IACA,SAAS;AAAA,MACP,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,YAAY;AAAA,IACd;AAAA,IACA,UAAU;AAAA,MACR,0BAA0B;AAAA,QACxB,mBAAmB;AAAA,UACjB,YAAY,CAAC,OAAO,QAAQ,SAAS,OAAO,MAAM;AAAA,QACpD,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA,OAAO;AAAA,MACL,yBAAyB;AAAA,MACzB,iCAAiC;AAAA,MACjC,iCAAiC;AAAA,MACjC,WAAW;AAAA,MACX,0BAA0B;AAAA,MAC1B,8BAA8B;AAAA,MAC9B,mBAAmB,CAAC,SAAS,OAAO;AAAA,MACpC,8CAA8C;AAAA,QAC5C;AAAA,QACA,EAAE,QAAQ,eAAe;AAAA,MAC3B;AAAA,MACA,qCAAqC;AAAA,QACnC;AAAA,QACA,EAAE,mBAAmB,MAAM,mBAAmB,KAAK;AAAA,MACrD;AAAA,MACA,wCAAwC;AAAA,QACtC;AAAA,QACA,EAAE,UAAU,aAAa,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;AAAA,QAC/D,EAAE,UAAU,aAAa,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,OAAO,CAAC,aAAa,cAAc;AAAA,IACnC,OAAO;AAAA,MACL,wCAAwC;AAAA,IAC1C;AAAA,EACF;AACF,CAAC;;;AKrDD,IAAM,gBAAgB;AAAA,EACpB,GAAG;AAAA,EACH,SAAS;AAAA,IACP;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/configs/recommended.ts","../src/rules/FilenamePascalCase.ts","../src/rules/NoMultilineImports.ts","../src/rules/SortImports.ts","../src/plugin.ts","../src/index.ts"],"sourcesContent":["import { createNodeResolver, importX } from 'eslint-plugin-import-x'\nimport stylistic from '@stylistic/eslint-plugin'\nimport { defineConfig } from 'eslint/config'\nimport tseslint from 'typescript-eslint'\n\nimport { plugin } from '../plugin'\n\n\nexport const recommended = defineConfig([\n {\n plugins: {\n '@stylistic': stylistic,\n 'import-x': importX,\n 'ai-rules': plugin,\n '@typescript-eslint': tseslint.plugin,\n },\n settings: {\n 'import-x/resolver-next': [\n createNodeResolver({\n extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],\n }),\n ],\n },\n rules: {\n 'ai-rules/sort-imports': 'error',\n 'ai-rules/no-multiline-imports': 'error',\n 'ai-rules/filename-pascal-case': 'error',\n 'max-len': 'off',\n 'import-x/no-duplicates': 'error',\n 'import-x/no-default-export': 'off',\n '@stylistic/semi': ['error', 'never'],\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports' },\n ],\n '@typescript-eslint/no-unused-vars': [\n 'error',\n { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },\n ],\n '@typescript-eslint/naming-convention': [\n 'error',\n { selector: 'interface', format: ['PascalCase'], prefix: ['I'] },\n { selector: 'typeAlias', format: ['PascalCase'], prefix: ['T'] },\n ],\n },\n },\n])\n\nexport default recommended\n","import type { Rule } from 'eslint'\nimport path from 'node:path'\n\n\nexport const filenamePascalCase: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: { description: 'Enforce PascalCase for file names' },\n schema: [],\n messages: {\n invalid: 'File name \"{{basename}}\" must be in PascalCase. Rename to \"{{expected}}\".',\n },\n },\n create(context) {\n const physicalFilename =\n // eslint 9 flat config\n (context as unknown as { getPhysicalFilename?: () => string }).getPhysicalFilename?.() ??\n (context as unknown as { physicalFilename?: string }).physicalFilename ??\n context.filename ??\n ''\n\n const cwd =\n (context as unknown as { getCwd?: () => string }).getCwd?.() ?? process.cwd()\n\n // Normaliza para posix para comparar com src/ e scripts/\n const normalizedPhysical = physicalFilename.split(path.sep).join('/')\n const normalizedCwd = cwd.split(path.sep).join('/')\n\n const relativePath = normalizedPhysical.startsWith(normalizedCwd)\n ? normalizedPhysical.slice(normalizedCwd.length + 1)\n : normalizedPhysical\n\n if (!relativePath.startsWith('src/') && !relativePath.startsWith('scripts/')) return {}\n\n const basename = path.basename(relativePath)\n\n if (basename === 'index.ts' || basename === 'index.tsx' || basename === 'index.js' || basename === 'index.jsx') return {}\n if (basename.endsWith('.d.ts')) return {}\n if (basename.endsWith('.css')) return {}\n\n const ext = path.extname(basename) // .ts\n // Para casos como Component.spec.ts -> ext .ts, nameWithoutExt Component.spec - tratamos mantendo só base antes do primeiro ponto?\n // Mantemos compat com original: remove apenas última extensão .ts/.tsx/.js/.jsx\n const nameWithoutExt = basename.replace(/\\.(ts|tsx|js|jsx)$/, '')\n\n if (!/^[A-Z][a-zA-Z0-9]*$/.test(nameWithoutExt)) {\n const pascalCase = nameWithoutExt\n .split(/[-_]/)\n .map(part => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n\n // Preserva extensão original (ex: .tsx)\n const originalExt = basename.slice(nameWithoutExt.length) || ext\n const expected = `${pascalCase}${originalExt}`\n\n context.report({\n loc: { line: 1, column: 0 },\n messageId: 'invalid',\n data: { basename, expected },\n })\n }\n\n return {}\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const noMultilineImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n fixable: 'code',\n docs: {\n description: 'Disallow multiline imports',\n },\n schema: [],\n messages: {\n multilineImport: 'Imports must be written on a single line.',\n },\n },\n\n create(context) {\n const sourceCode = context.sourceCode\n\n return {\n ImportDeclaration(node) {\n const text = sourceCode.getText(node)\n\n if (!text.includes('\\n')) {\n return\n }\n\n context.report({\n node,\n messageId: 'multilineImport',\n\n fix(fixer) {\n const firstToken = sourceCode.getFirstToken(node)\n const lastToken = sourceCode.getLastToken(node)\n\n if (!firstToken || !lastToken) {\n return null\n }\n\n let importText = sourceCode.getText(node)\n\n importText = importText\n .replace(/\\s*\\{\\s*/g, ' { ')\n .replace(/\\s*\\}\\s*/g, ' } ')\n .replace(/\\s*,\\s*/g, ', ')\n .replace(/\\s+/g, ' ')\n .replace(/ \\{ /g, ' { ')\n .replace(/ \\} /g, ' } ')\n .replace(/\\s+from\\s+/g, ' from ')\n .trim()\n // Corrige espaços colapsados em torno de { e }\n .replace(/\\{ \\s+/g, '{ ')\n .replace(/\\s+ \\}/g, ' }')\n\n return fixer.replaceText(node, importText)\n },\n })\n },\n }\n },\n}\n","import type { Rule } from 'eslint'\n\n\nexport const sortImports: Rule.RuleModule = {\n meta: {\n type: 'layout',\n docs: {\n description: 'Sort imports by group and line length descending, collapsing multiline imports',\n },\n fixable: 'code',\n schema: [],\n messages: {\n sortRequired: 'As importações devem estar ordenadas por grupo e tamanho da linha, ocupando uma única linha.',\n },\n },\n create(context) {\n return {\n Program(node) {\n const sourceCode = context.sourceCode\n const content = sourceCode.text\n\n const newContent = getSortedContent(content)\n\n if (newContent && newContent !== content) {\n context.report({\n node,\n messageId: 'sortRequired',\n fix(fixer) {\n return fixer.replaceText(node, newContent)\n },\n })\n }\n },\n }\n },\n}\n\n// ---------------------------------------------------------------------------\n// Tipos auxiliares\n// ---------------------------------------------------------------------------\ntype TImportItem = {\n line: string\n from: string\n}\n\n// ---------------------------------------------------------------------------\n// Lógica Core - exportada para teste e reutilização\n// ---------------------------------------------------------------------------\nexport function getSortedContent(content: string): string | null {\n const collapseMultiline = (match: string) => {\n return match\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/.*$/gm, '')\n .replace(/\\s+/g, ' ')\n }\n\n const normalizedContent = content\n .replace(/import\\s+([^'\";]+?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n // Apenas re-exports válidos: export { ... } from / export * from / export * as X from / export type { ... } from\n .replace(/export\\s+(?:type\\s+)?(?:\\{[^}]*\\}|\\*(?:\\s+as\\s+\\w+)?)\\s+from\\s+(['\"][^'\"]+['\"])/g, collapseMultiline)\n\n const lines: string[] = normalizedContent.split('\\n')\n\n const directiveLines: string[] = []\n const reactFirstLine: string[] = []\n const externalLines: TImportItem[] = []\n const internalLines: TImportItem[] = []\n const reExportLines: TImportItem[] = []\n const nonImportLines: string[] = []\n\n let inImportBlock = false\n let canAcceptDirectives = true\n\n for (let i = 0; i < lines.length; i++) {\n const trimmed = lines[i].trim()\n\n if (\n /^(function|const|let|var|class|interface|enum)\\b/.test(trimmed) ||\n (/^(type|export)\\b/.test(trimmed) && !/ from ['\"]/.test(trimmed) && !/^export\\s*\\{[^}]*\\}\\s*from/.test(trimmed) && !/^export\\s*\\*/.test(trimmed)) ||\n trimmed.startsWith('}')\n ) {\n canAcceptDirectives = false\n }\n\n if (inImportBlock && trimmed === '') continue\n\n if (canAcceptDirectives && /^['\"]use (client|server|strict)['\"];?$/.test(trimmed)) {\n directiveLines.push(lines[i])\n continue\n }\n\n const isReExport =\n /^export\\s+(type\\s+)?\\{[^}]*\\}\\s+from\\s+['\"]/.test(trimmed) ||\n /^export\\s+\\*(\\s+as\\s+\\w+)?\\s+from\\s+['\"]/.test(trimmed)\n\n if (isReExport) {\n const m = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n if (m) reExportLines.push({ line: lines[i], from: m[1] })\n inImportBlock = true\n canAcceptDirectives = false\n continue\n }\n\n const isImport = /^import\\s/.test(trimmed) || /^import\\{/.test(trimmed)\n\n if (isImport) {\n inImportBlock = true\n canAcceptDirectives = false\n\n const fromMatch = lines[i].match(/from\\s+['\"]([^'\"]+)['\"]/)\n const seMatch = lines[i].match(/^import\\s+['\"]([^'\"]+)['\"]/)\n const from = fromMatch ? fromMatch[1] : seMatch ? seMatch[1] : null\n\n if (!from) {\n nonImportLines.push(lines[i])\n continue\n }\n\n const isTypeOnly = /^import\\s+type\\b/.test(trimmed)\n const isInternal = from.startsWith('.') || from.startsWith('@/')\n const isReactEntry = !isTypeOnly && (from === 'react' || from.startsWith('react/'))\n\n if (isReactEntry) {\n reactFirstLine.push(lines[i])\n } else if (isInternal) {\n internalLines.push({ line: lines[i], from })\n } else {\n externalLines.push({ line: lines[i], from })\n }\n continue\n }\n\n inImportBlock = false\n nonImportLines.push(lines[i])\n }\n\n if (reactFirstLine.length === 0 && externalLines.length === 0 && internalLines.length === 0 && reExportLines.length === 0) {\n return null\n }\n\n const byLengthDesc = (a: TImportItem, b: TImportItem) =>\n b.line.length !== a.line.length ? b.line.length - a.line.length : a.line.localeCompare(b.line)\n\n externalLines.sort(byLengthDesc)\n internalLines.sort(byLengthDesc)\n reExportLines.sort(byLengthDesc)\n\n const blocks: string[] = []\n\n if (directiveLines.length > 0) blocks.push(directiveLines.join('\\n'))\n\n const externalBlock = [...reactFirstLine, ...externalLines.map(i => i.line)]\n if (externalBlock.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(externalBlock.join('\\n'))\n }\n\n if (internalLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(internalLines.map(i => i.line).join('\\n'))\n }\n\n if (reExportLines.length > 0) {\n if (blocks.length > 0) blocks.push('')\n blocks.push(reExportLines.map(i => i.line).join('\\n'))\n }\n\n const rest = nonImportLines.join('\\n').replace(/^\\n+/, '')\n\n let newContent: string\n if (blocks.length > 0 && rest.length > 0) {\n newContent = blocks.join('\\n') + '\\n\\n\\n' + rest\n } else if (blocks.length > 0) {\n newContent = blocks.join('\\n') + '\\n'\n } else {\n newContent = rest\n }\n\n return newContent\n}\n","import { filenamePascalCase } from './rules/FilenamePascalCase'\nimport { noMultilineImports } from './rules/NoMultilineImports'\nimport { sortImports } from './rules/SortImports'\n\n\nexport const plugin = {\n meta: {\n name: 'eslint-plugin-ai-rules',\n version: '0.1.0',\n },\n rules: {\n 'filename-pascal-case': filenamePascalCase,\n 'no-multiline-imports': noMultilineImports,\n 'sort-imports': sortImports,\n },\n} as const\n","import { recommended } from './configs/recommended'\nimport { plugin } from './plugin'\n\nexport * from './rules/index'\n\n\nconst aiGuardPlugin = {\n ...plugin,\n configs: {\n recommended,\n },\n}\n\nexport default a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AAC,GAAG,EAAE;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;AKxCD,IAAM,gBAAgB;AAAA,EACpB,GAAG;AAAA,EACH,SAAS;AAAA,IACP;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-ai-rules",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "ESLint plugin com regras úteis para projetos com ESLint - AI Rules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
"prebuild": "npm run clean",
|
|
22
22
|
"build": "tsup",
|
|
23
23
|
"dev": "tsup --watch",
|
|
24
|
+
"prelint": "npm run build",
|
|
24
25
|
"lint": "eslint .",
|
|
25
26
|
"typecheck": "tsc --noEmit",
|
|
26
|
-
"verify": "npm run typecheck && npm run
|
|
27
|
+
"verify": "npm run typecheck && npm run build && npm run lint && npm pack --dry-run",
|
|
27
28
|
"prepack": "npm run build",
|
|
28
29
|
"prepublishOnly": "git diff --quiet || (echo '✖ uncommitted changes — commit before publishing' && exit 1) && npm run verify",
|
|
29
30
|
"postpublish": "echo '✔ published. Run: git push --follow-tags'"
|
|
@@ -53,7 +54,6 @@
|
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/node": "^22.0.0",
|
|
55
56
|
"eslint": "^9.0.0",
|
|
56
|
-
"jiti": "^2.7.0",
|
|
57
57
|
"tsup": "^8.0.0",
|
|
58
58
|
"tsx": "^4.0.0",
|
|
59
59
|
"typescript": "^5.6.0"
|