{"id":19560218,"url":"https://github.com/fe-pirl/code-specification-unid","last_synced_at":"2025-04-26T23:32:51.433Z","repository":{"id":48883178,"uuid":"353696828","full_name":"FE-PIRL/code-specification-unid","owner":"FE-PIRL","description":"🔥 Code specification unified dependency, support react/vue2/vue3/svelte3.","archived":false,"fork":false,"pushed_at":"2021-07-22T03:44:02.000Z","size":633,"stargazers_count":32,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T15:56:07.408Z","etag":null,"topics":["code-quantity","code-specification","commitlint","eslint","husky","lint-staged","prettier","stylelint"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FE-PIRL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-01T12:43:37.000Z","updated_at":"2025-01-17T16:07:00.000Z","dependencies_parsed_at":"2022-09-16T04:01:19.121Z","dependency_job_id":null,"html_url":"https://github.com/FE-PIRL/code-specification-unid","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FE-PIRL%2Fcode-specification-unid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FE-PIRL%2Fcode-specification-unid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FE-PIRL%2Fcode-specification-unid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FE-PIRL%2Fcode-specification-unid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FE-PIRL","download_url":"https://codeload.github.com/FE-PIRL/code-specification-unid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251068040,"owners_count":21531475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-quantity","code-specification","commitlint","eslint","husky","lint-staged","prettier","stylelint"],"created_at":"2024-11-11T05:06:30.629Z","updated_at":"2025-04-26T23:32:50.957Z","avatar_url":"https://github.com/FE-PIRL.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# code-specification-unid\n\nEnglish | [简体中文](https://github.com/FE-PIRL/code-specification-unid/blob/master/README_CN.md)\n\nProduced to solve the problem of inconsistent code specifications for multiple projects in the team.\n\nIt's a collection of unified configuration files including `prettier`, `eslint`, `stylelint`, `husky`, `lint-staged`, and `commitlint` support `react`、`vue2`、`vue3` and `svelte3`.\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![License: MIT][license-image]][license-url]\n\n\n\u003e * **eslint** helps you find js errors and improve the quality of js code\n\u003e * **stylelint** helps you find css errors and improve the quality of css code\n\u003e * **Prettier** helps you format the code, unify code format\n\u003e * **Husky** and **lint-staged** run code inspections before submitting code to improve the quality of online code\n\u003e * **commitlint** helps you unify the commit message format\n\n\n# Features\n\n* 🔖 All projects uniformly use an agreed code specification;\n* 📦 Put a large number of third-party dependencies back to simplify business code;\n* ✏️ On the basis of inheriting the unified specification, still provide customization capabilities;\n* 🏆 Support React, Vue2, Vue3 projects, and support file name verification;\n\n# Installation\n\n```\nnpm install code-specification-unid --save-dev\n```\nOr \n\n```\nyarn add code-specification-unid -D\n```\n\u003e Note: Since `code-specification-unid` has already consolidated most of the code specification-related dependency packages that may be used, there is no need to reinstall the following dependencies.\nIf they are already installed, please delete them by yourself (including the corresponding configuration file):\n```json\n\"@babel/core\": \"^7.12.10\",\n\"@babel/eslint-parser\": \"^7.12.1\",\n\"@babel/plugin-proposal-class-properties\": \"^7.13.0\",\n\"@babel/plugin-proposal-decorators\": \"^7.13.5\",\n\"@babel/preset-env\": \"^7.12.11\",\n\"@babel/preset-react\": \"^7.12.10\",\n\"@babel/preset-typescript\": \"^7.12.7\",\n\"@commitlint/cli\": \"^11.0.0\",\n\"@commitlint/config-conventional\": \"^11.0.0\",\n\"@typescript-eslint/eslint-plugin\": \"^4.28.1\",\n\"@typescript-eslint/parser\": \"^4.28.1\",\n\"eslint\": \"^7.29.0\",\n\"eslint-config-prettier\": \"^8.3.0\",\n\"eslint-formatter-pretty\": \"^4.1.0\",\n\"eslint-plugin-babel\": \"^5.3.0\",\n\"eslint-plugin-compat\": \"^3.1.1\",\n\"eslint-plugin-eslint-comments\": \"^3.1.1\",\n\"eslint-plugin-filename\": \"^1.0.0\",\n\"eslint-plugin-import\": \"^2.17.3\",\n\"eslint-plugin-jest\": \"^24.0.1\",\n\"eslint-plugin-jsx-a11y\": \"^6.2.0\",\n\"eslint-plugin-markdown\": \"^1.0.0\",\n\"eslint-plugin-prettier\": \"^3.4.0\",\n\"eslint-plugin-promise\": \"^4.1.1\",\n\"eslint-plugin-react\": \"^7.22.0\",\n\"eslint-plugin-react-hooks\": \"^4.2.0\",\n\"eslint-plugin-svelte3\": \"^3.2.0\",\n\"eslint-plugin-unicorn\": \"^20.0.0\",\n\"eslint-plugin-vue\": \"^7.5.0\",\n\"husky\": \"^4.3.8\",\n\"lint-staged\": \"^10.5.3\",\n\"prettier\": \"^2.3.2\",\n\"prettier-plugin-svelte\": \"^2.2.0\",\n\"stylelint\": \"^13.7.0\",\n\"stylelint-config-css-modules\": \"^2.2.0\",\n\"stylelint-config-prettier\": \"^8.0.2\",\n\"stylelint-config-rational-order\": \"^0.1.2\",\n\"stylelint-config-standard\": \"^20.0.0\",\n\"stylelint-declaration-block-no-ignored-properties\": \"^2.1.0\",\n\"stylelint-no-unsupported-browser-features\": \"^4.1.4\",\n\"stylelint-order\": \"^4.0.0\",\n\"stylelint-prettier\": \"^1.1.2\",\n\"stylelint-scss\": \"^3.19.0\"\n```\n\n# Configuration\n\n### 1. Create configuration files as below;\n\nin `.eslintrc.js`\n\n```js\nmodule.exports = {\n  extends: [require.resolve('code-specification-unid/dist/eslintReact')],\n  rules: {\n    // your rules\n  },\n};\n```\n\n\u003e Note that for different projects, please import different eslint configuration packages\n\u003e\n\u003e react corresponds to `eslintReact`\n\u003e\n\u003e vue2 corresponds to `eslintVue2`\n\u003e\n\u003e vue3 corresponds to `eslintVue3`\n\u003e\n\u003e svelte corresponds to `eslintSvelte`\n\nin `.stylelintrc.js`\n\n```js\nmodule.exports = {\n  extends: [require.resolve('code-specification-unid/dist/stylelint')],\n  rules: {\n    // your rules\n  },\n};\n```\n\nin `.prettierrc.js`\n\n```js\nconst spec = require('code-specification-unid');\n\nmodule.exports = {\n    ...spec.prettier,\n    // your rules\n};\n```\n\nin `.huskyrc.js`\n\n```js\nconst spec = require('code-specification-unid');\n\nmodule.exports = {\n    ...spec.husky,\n    // your rules\n};\n```\n\nin `.lintstagedrc.js`\n\n```js\nconst spec = require('code-specification-unid');\n\nmodule.exports = {\n    ...spec.lintstaged,\n    // your rules\n};\n```\n\nin `.commitlintrc.js`\n\n```js\nconst spec = require('code-specification-unid');\n\nmodule.exports = {\n    ...spec.commitlint,\n    // your rules\n};\n```\n\n\u003e Note: The format types of submitted message are `'upd','feat','fix','refactor','docs','chore','style','revert'`, for example: `feat: add support for i18n`\n\n#### File name verification (optional)\n\nBy default, file name verification does not require any configuration. The default rule is to support `camelcase` or `pascalcase` style file names.\n\nIt relies on the [`eslint-plugin-filename`](https://github.com/benyasin/eslint-plugin-filename) plugin to complete, and supports two forms of alias and custom regular.\n\nThe built-in aliases are `pascalcase`/`PascalCase`, `camelcase`/`camelCase`, `snakecase`/`snake_case`, `kebabcase`/`kebab-case`,\nIt also supports passing in multiple aliases in the form of an array.\n\nE.g:\n\n```js\n  rules: {\n    'filename/match': [2, 'camelcase'],\n  },\n```\n\nOr\n\n```js\n  rules: {\n    'filename/match': [2, ['camelcase','pascalcase']], //default configuration\n  },\n```\n\nIf the above built-in aliases cannot meet your needs, you can also customize regular expressions, for example:\n\n```js\n'filename/match': [2, /^([a-z]+-)*[a-z]+(?:\\..*)?$/],\n```\n\nYou can even use different rules for different file types, for example:\n\n```js\n'filename/match': [2, { '.js': 'camelCase', '.ts': /^([a-z]+-)*[a-z]+(?:\\..*)?$/ }],\n```\n\n### 2. Call command\n\nIf it is a react project, add the following command to the script of your project package.json:\n```\n\"lint\": \"npm run lint:js \u0026\u0026 npm run lint:css \u0026\u0026 npm run lint:format\",\n\"lint:js\": \"eslint src --fix --ext .js,.jsx,.ts,.tsx --cache --cache-location node_modules/.cache/eslint/\",\n\"lint:css\": \"stylelint --fix \\\"src/**/*.{less,postcss,css,scss}\\\" --cache --cache-location node_modules/.cache/stylelint/\",\n\"lint:format\": \"prettier --write  \\\"src/**/*.{js,json,ts,tsx,css,less,scss,html,md}\\\"\",\n```\n\nIf it is a vue project, add the following command to the script of your project package.json:\n\n```\n\"lint\": \"npm run lint:js \u0026\u0026 npm run lint:css \u0026\u0026 npm run lint:format\",\n\"lint:js\": \"eslint src --fix --ext .js,.jsx,.ts,.tsx,.vue --cache --cache-location node_modules/.cache/eslint/\",\n\"lint:css\": \"stylelint --fix \\\"src/**/*.{less,postcss,css,scss,vue}\\\" --cache --cache-location node_modules/.cache/stylelint/\",\n\"lint:format\": \"prettier --write  \\\"src/**/*.{js,json,ts,tsx,vue,css,less,scss,html,md}\\\"\",\n```\n\nIf it is a svelte project, add the following command to the script of your project package.json:\n\n```\n\"lint\": \"npm run lint:js \u0026\u0026 npm run lint:css \u0026\u0026 npm run lint:format\",\n\"lint:js\": \"eslint src --fix --ext .js,.jsx,.ts,.tsx,.svelte --cache --cache-location node_modules/.cache/eslint/\",\n\"lint:css\": \"stylelint --fix \\\"src/**/*.{less,postcss,css,scss,svelte}\\\" --cache --cache-location node_modules/.cache/stylelint/\",\n\"lint:format\": \"prettier --write  \\\"src/**/*.{js,json,ts,tsx,svelte,css,less,scss,html,md}\\\"\",\n```\n\n### Usage example\n\nFor a complete usage example, please refer to this [react-snowpack](https://github.com/benyasin/code-specification-unid-demo) example\n\n# Changelog\n\n1.0.13\n\n* add supports for style order auto fixing\n\n1.0.12\n\n* fix stylelint some default rules\n\n1.0.11\n\n* add ESLint support for Typescript 3.8+ `import type` syntax\n\n1.0.9\n\n* add stylelint-scss plugin\n\n1.0.7\n\n* add supports for svelte\n\n1.0.5\n\n* fix problem with filename validation expired when in vue project\n\n1.0.3\n\n* add eslint ignore pattern for `.*.js`\n\n1.0.0 \n\n* Initial release\n\n\n# License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/code-specification-unid.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/code-specification-unid\n[downloads-image]: https://img.shields.io/npm/dm/code-specification-unid.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/code-specification-unid\n[license-image]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\n[license-url]: https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffe-pirl%2Fcode-specification-unid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffe-pirl%2Fcode-specification-unid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffe-pirl%2Fcode-specification-unid/lists"}