Skip to content

Commit f069f5a

Browse files
committed
working eslint plugin
1 parent 6a40721 commit f069f5a

File tree

7 files changed

+60
-12
lines changed

7 files changed

+60
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
"tsx": "^4.20.3",
5353
"typescript": "^5.9.2"
5454
}
55-
}
55+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { dirname } from 'path';
2+
import { fileURLToPath } from 'url';
3+
import { FlatCompat } from '@eslint/eslintrc';
4+
import tsParser from '@typescript-eslint/parser';
5+
import zeroUiPlugin from 'eslint-plugin-react-zero-ui';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = dirname(__filename);
9+
10+
/* Convert “old-style” shareable configs shipped by Next.js */
11+
const compat = new FlatCompat({ baseDirectory: __dirname });
12+
13+
export default [
14+
/* Global ignores ─────────────────────────────────────────────── */
15+
{ ignores: ['.zero-ui/**', '.next/**', 'node_modules/**'] },
16+
17+
/* Next presets (core-web-vitals + TS) */
18+
...compat.extends('next/core-web-vitals', 'next/typescript'),
19+
20+
/* Your Zero-UI rule ─────────────────────────────────────────── */
21+
{
22+
files: ['**/*.{tsx,jsx}'],
23+
languageOptions: { parser: tsParser, parserOptions: { project: './tsconfig.json' } },
24+
plugins: {
25+
'react-zero-ui': zeroUiPlugin, // load from workspace
26+
},
27+
rules: {
28+
'react-zero-ui/require-data-attr': 'error',
29+
// any local overrides…
30+
'@typescript-eslint/no-unused-vars': ['warn'],
31+
'no-console': ['warn', { allow: ['warn', 'error'] }],
32+
},
33+
},
34+
];

packages/eslint-plugin-react-zero-ui/__tests__/fixtures/next/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"dev": "rm -rf .next && next dev",
66
"build": "next build",
77
"start": "next start",
8-
"clean": "rm -rf .next node_modules package-lock.json"
8+
"clean": "rm -rf .next node_modules package-lock.json",
9+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
910
},
1011
"dependencies": {
1112
"next": "^15.0.0",
@@ -21,4 +22,4 @@
2122
"tailwindcss": "^4.1.10",
2223
"typescript": "5.8.3"
2324
}
24-
}
25+
}

packages/eslint-plugin-react-zero-ui/index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/eslint-plugin-react-zero-ui/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"dist"
1212
],
1313
"scripts": {
14-
"build": "tsc -p tsconfig.json"
14+
"build": "tsc -p tsconfig.json",
15+
"prepack": "pnpm build"
1516
},
1617
"peerDependencies": {
1718
"eslint": "^9 || ^8",
@@ -21,4 +22,4 @@
2122
"@typescript-eslint/utils": "^8.0.0",
2223
"typescript": "^5.8.3"
2324
}
24-
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import requireDataAttr from './rules/require-data-attr.js';
2+
3+
const rules = { 'require-data-attr': requireDataAttr } as const;
4+
5+
// recommended config for users
6+
const configs = { recommended: { plugins: ['react-zero-ui'], rules: { 'react-zero-ui/require-data-attr': 'error' } } } as const;
7+
8+
export default { rules, configs };
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
{ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", "declaration": true, "outDir": "dist" }, "include": ["src"] }
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"declaration": true,
6+
"outDir": "dist"
7+
},
8+
"include": [
9+
"src"
10+
]
11+
}

0 commit comments

Comments
 (0)