{"_id":"@allah-prime/eslint","name":"@allah-prime/eslint","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@allah-prime/eslint","version":"0.0.1","packageManager":"pnpm@9.1.0","type":"module","description":"My shared ESLint & Prettier configuration for projects","repository":{"type":"git","url":"git+https://github.com/allah-prime/allah-eslint.git"},"keywords":["eslint","prettier","antd","ant","design","pro"],"license":"ISC","author":{"name":"qixian.cs@outlook.com"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","prepublishOnly":"pnpm run build"},"publishConfig":{"access":"public"},"pnpm":{"overrides":{"eslint":"9.39.2"}},"dependencies":{"@eslint/compat":"2.0.0","@eslint/js":"9.39.2","eslint-config-prettier":"10.1.8","eslint-plugin-react":"7.37.5","eslint-plugin-react-hooks":"7.0.1","eslint-plugin-unused-imports":"4.3.0","eslint-plugin-vue":"10.6.2","globals":"17.0.0","typescript":"5.9.3","typescript-eslint":"8.52.0"},"peerDependencies":{"eslint":"9.39.2","prettier":"3.7.4"},"devDependencies":{"@types/node":"25.0.3","eslint":"9.39.2","jiti":"2.6.1","semantic-release":"^25.0.3","vitest":"4.0.16"},"gitHead":"d60ce846e37dda1ecf0df985721369fcbb0922c0","_id":"@allah-prime/eslint@0.0.1","bugs":{"url":"https://github.com/allah-prime/allah-eslint/issues"},"homepage":"https://github.com/allah-prime/allah-eslint#readme","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-Vd/cLfYeGbM5DTIGN0WQu3U/X64y4cZ+pizAHtBRIwhEBmiyYjwm+4c/eXkya04vJkVpRYmwNrpb7z4ch6/TEg==","shasum":"5e87b9a5f8f8c6a10ba4a44685efad6c9a6e99b0","tarball":"https://registry.npmjs.org/@allah-prime/eslint/-/eslint-0.0.1.tgz","fileCount":8,"unpackedSize":14850,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD95cJ10RcX1wznYCKzzbqUJ936P9onSIIMd7i4M9B+hwIgK6Daeqbh44IBEGbbJnd0rgPOEoU5WTCZnC9N1jYzY0A="}]},"_npmUser":{"name":"allahbin2","email":"allahbin1996@gmail.com"},"directories":{},"maintainers":[{"name":"allahbin2","email":"allahbin1996@gmail.com"},{"name":"allahbin","email":"569693942@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/eslint_0.0.1_1771223398566_0.42582272897988593"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-16T06:29:58.465Z","0.0.1":"2026-02-16T06:29:58.705Z","modified":"2026-02-16T06:29:58.945Z"},"maintainers":[{"name":"allahbin2","email":"allahbin1996@gmail.com"},{"name":"allahbin","email":"569693942@qq.com"}],"description":"My shared ESLint & Prettier configuration for projects","homepage":"https://github.com/allah-prime/allah-eslint#readme","keywords":["eslint","prettier","antd","ant","design","pro"],"repository":{"type":"git","url":"git+https://github.com/allah-prime/allah-eslint.git"},"author":{"name":"qixian.cs@outlook.com"},"bugs":{"url":"https://github.com/allah-prime/allah-eslint/issues"},"license":"ISC","readme":"# @allah/eslint\r\n\r\nMy shared ESLint & Prettier configuration for projects.\r\n这是一个基于 ESLint 9+ 和 Prettier 的共享配置包，提供了 React 和 Vue 的开箱即用配置。\r\n\r\n## 核心特性\r\n\r\n- **TypeScript**: 完整的类型检查支持。\r\n- **Prettier**: 集成 Prettier 用于代码格式化，通过 `eslint-config-prettier` 解决冲突。\r\n- **React**: 包含 Hooks 和 JSX 的最佳实践。\r\n- **Vue**: 支持 Vue 3 + TypeScript。\r\n\r\n## 参考文档\r\n\r\n本项目配置参考了以下官方文档：\r\n\r\n- [ESLint Shareable Configs](https://eslint.org/docs/latest/extend/shareable-configs)\r\n- [ESLint Rules](https://eslint.org/docs/latest/rules/)\r\n- [TypeScript ESLint Rules](https://typescript-eslint.io/rules/)\r\n- [React Plugin Rules](https://github.com/jsx-eslint/eslint-plugin-react)\r\n- [Vue Plugin Rules](https://eslint.vuejs.org/rules/)\r\n- [Prettier Options](https://prettier.io/docs/en/options.html)\r\n\r\n---\r\n\r\n## 使用指南\r\n\r\n### 1. 安装依赖\r\n\r\n```bash\r\npnpm add -D eslint prettier @allah/eslint\r\n```\r\n\r\n### 2. 配置 Prettier\r\n\r\n建议在项目根目录下创建 `.prettierrc` 以保持格式化风格一致：\r\n\r\n```json\r\n{\r\n  \"tabWidth\": 2,\r\n  \"useTabs\": false,\r\n  \"singleQuote\": true,\r\n  \"trailingComma\": \"none\",\r\n  \"printWidth\": 100\r\n}\r\n```\r\n\r\n### 3. 配置.editorconfig\r\n\r\n需要在项目下配置`.editorconfig`文件以保持格式化风格统一\r\n\r\n```editorconfig\r\n# http://editorconfig.org\r\nroot = true\r\n\r\n[*]\r\nindent_style = space\r\nindent_size = 2\r\nend_of_line = lf\r\ncharset = utf-8\r\ntrim_trailing_whitespace = true\r\ninsert_final_newline = true\r\n\r\n[*.md]\r\ntrim_trailing_whitespace = false\r\n\r\n[Makefile]\r\nindent_style = tab\r\n```\r\n\r\n### 3. 配置 ESLint\r\n\r\n根据你的项目类型选择对应的配置。\r\n\r\n#### 🅰️ React + TypeScript 项目\r\n\r\n在项目根目录下创建 `eslint.config.js`：\r\n\r\n```javascript\r\nimport allahConfig from '@allah/eslint';\r\n\r\nexport default [\r\n  ...allahConfig,\r\n  {\r\n    files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],\r\n    rules: {\r\n      camelcase: 0\r\n    }\r\n  }\r\n];\r\n```\r\n\r\n#### 🅱️ Vue 3 + TypeScript 项目\r\n\r\n在项目根目录下创建 `eslint.config.js`，注意引入路径为 `@allah/eslint/dist/vue`：\r\n\r\n```javascript\r\nimport allahConfig from '@allah/eslint/dist/vue';\r\n\r\nexport default defineConfig([\r\n  ...allahConfig,\r\n  {\r\n    files: ['**/*.{js,mjs,cjs,ts,vue}'],\r\n    rules: {\r\n      // 要求使用模板字面量而非字符串连接\r\n      'prefer-template': 2\r\n    }\r\n  }\r\n]);\r\n```\r\n\r\n### 4. VSCode 配置推荐\r\n\r\n为了获得最佳的开发体验，建议在 `.vscode/settings.json` 中添加以下配置，实现保存自动格式化和修复：\r\n\r\n```json\r\n{\r\n  \"editor.formatOnSave\": true,\r\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\r\n  \"editor.codeActionsOnSave\": {\r\n    \"source.fixAll.eslint\": \"explicit\"\r\n  },\r\n  \"eslint.validate\": [\"javascript\", \"javascriptreact\", \"typescript\", \"typescriptreact\", \"vue\"]\r\n}\r\n```\r\n\r\n#### 自定义的示例\r\n\r\n你有也可以自定义对eslint的规则进行配置，示例如下\r\n\r\n```ts\r\nimport js from '@eslint/js';\r\nimport globals from 'globals';\r\nimport reactPlugin from 'eslint-plugin-react';\r\nimport reactHooks from 'eslint-plugin-react-hooks';\r\n\r\nexport default [\r\n  // 1. 忽略文件\r\n  {\r\n    ignores: [\r\n      'dist',\r\n      'node_modules',\r\n      'lambda',\r\n      'scripts',\r\n      'config',\r\n      '.history',\r\n      'public',\r\n      '.umi',\r\n      'mock',\r\n      'service.js',\r\n      'es',\r\n      'lib'\r\n    ]\r\n  },\r\n\r\n  // 2. 基础配置 + React 配置\r\n  {\r\n    files: ['**/*.{ts,tsx,mjs,cjs}'],\r\n    languageOptions: {\r\n      ecmaVersion: 'latest',\r\n      sourceType: 'module',\r\n      // 必须开启 JSX 解析\r\n      parserOptions: {\r\n        ecmaFeatures: {\r\n          jsx: true\r\n        }\r\n      },\r\n      globals: {\r\n        ...globals.browser,\r\n        ...globals.node\r\n      }\r\n    },\r\n    // 注册插件\r\n    plugins: {\r\n      react: reactPlugin,\r\n      'react-hooks': reactHooks\r\n    },\r\n    rules: {\r\n      // --- 基础规则 ---\r\n      ...js.configs.recommended.rules,\r\n      'prefer-template': 'error', // 你的核心需求\r\n\r\n      // --- React 规则 ---\r\n      ...reactPlugin.configs.recommended.rules,\r\n      ...reactPlugin.configs['jsx-runtime'].rules, // 如果你使用 React 17+ (不需要手动 import React)\r\n\r\n      // --- React Hooks 规则 ---\r\n      ...reactHooks.configs.recommended.rules,\r\n\r\n      // 自定义调整\r\n      'react/prop-types': 'off' // 如果你觉得写 PropTypes 太麻烦可以关掉\r\n    },\r\n    // 自动检测 React 版本\r\n    settings: {\r\n      react: {\r\n        version: 'detect'\r\n      }\r\n    }\r\n  }\r\n];\r\n```\r\n","readmeFilename":"README.md","_rev":"1-3456342c047697903877cd0f3f3d29e6"}