Skip to content

Commit

Permalink
feat(component): init project
Browse files Browse the repository at this point in the history
  • Loading branch information
hankliu62 committed Apr 15, 2024
0 parents commit 19acb5a
Show file tree
Hide file tree
Showing 1,802 changed files with 140,493 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 🎨 editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
167 changes: 167 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
const eslintrc = {
extends: [
'airbnb',
'prettier',
'plugin:compat/recommended',
'plugin:jest/recommended',
'plugin:react/recommended',
'plugin:import/typescript',
'plugin:markdown/recommended',
],
env: {
browser: true,
node: true,
jasmine: true,
jest: true,
es6: true,
},
settings: {
react: {
version: '17.0.2',
},
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
parser: '@typescript-eslint/parser',
plugins: ['react', 'babel', 'jest', '@typescript-eslint', 'react-hooks', 'unicorn', 'markdown'],
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/no-unused-vars': [2, { args: 'none' }],
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 2,
'@typescript-eslint/consistent-type-imports': 2,
},
},
{
// In v2, explicitly apply eslint-plugin-markdown's `markdown`
// processor on any Markdown files you want to lint.
files: ['components/*/demo/*.md'],
processor: 'markdown/markdown',
},
{
// In v2, configuration for fenced code blocks is separate from the
// containing Markdown file. Each code block has a virtual filename
// appended to the Markdown file's path.
files: [
'components/*/demo/*.md/*.ts',
'components/*/demo/*.md/*.tsx',
'components/*/demo/*.md/*.js',
'components/*/demo/*.md/*.jsx',
],
// Configuration for fenced code blocks goes with the override for
// the code block's virtual filename, for example:
parserOptions: {
ecmaFeatures: {
impliedStrict: true,
},
},
globals: {
React: true,
ReactDOM: true,
mountNode: true,
},
rules: {
indent: 0,
'default-case': 0,
'eol-last': 0,
'no-console': 0,
'no-plusplus': 0,
'no-script-url': 0,
'prefer-rest-params': 0,
'compat/compat': 0,
'class-methods-use-this': 0,
'react/no-access-state-in-setstate': 0,
'react/destructuring-assignment': 0,
'react/no-multi-comp': 0,
'react/no-array-index-key': 0,
'jsx-a11y/href-no-hash': 0,
'jsx-a11y/control-has-associated-label': 0,
'import/no-extraneous-dependencies': 0,
'react/jsx-no-constructed-context-values': 0,
'react/no-unstable-nested-components': 0,
},
},
],
rules: {
'react/jsx-one-expression-per-line': 0,
'react/prop-types': 0,
'react/forbid-prop-types': 0,
'react/jsx-indent': 0,
'react/jsx-wrap-multilines': ['error', { declaration: false, assignment: false }],
'react/jsx-filename-extension': 0,
'react/state-in-constructor': 0,
'react/jsx-props-no-spreading': 1,
'react/require-default-props': 0,
'react/sort-comp': 0,
'react/display-name': 0,
'react/static-property-placement': 0,
'react/jsx-no-bind': 0, // Should not check test file
'react/no-find-dom-node': 0,
'react/no-unused-prop-types': 0,
'react/default-props-match-prop-types': 0,
'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks
'react/function-component-definition': 0,
'react/no-unused-class-component-methods': 0,
'import/extensions': 0,
'import/no-cycle': 0,
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'site/**',
'tests/**',
'scripts/**',
'**/*.test.js',
'**/__tests__/*',
'*.config.js',
'**/*.md',
],
},
],
'jsx-a11y/no-static-element-interactions': 0,
'jsx-a11y/anchor-has-content': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0,
// label-has-for has been deprecated
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
'jsx-a11y/label-has-for': 0,

'comma-dangle': ['error', 'always-multiline'],
'no-underscore-dangle': 0,
// for (let i = 0; i < len; i++)
'no-plusplus': 0,
// https://eslint.org/docs/rules/no-continue
// labeledLoop is conflicted with `eslint . --fix`
'no-continue': 0,
// ban this for Number.isNaN needs polyfill
'no-restricted-globals': 0,
'max-classes-per-file': 0,

'jest/no-test-callback': 0,
'jest/expect-expect': 0,
'jest/no-done-callback': 0,
'jest/valid-title': 0,
'jest/no-conditional-expect': 0,

'unicorn/better-regex': 2,
'unicorn/prefer-string-trim-start-end': 2,
'unicorn/expiring-todo-comments': 2,
'unicorn/no-abusive-eslint-disable': 2,

// https://github.com/typescript-eslint/typescript-eslint/issues/2540#issuecomment-692866111
'no-use-before-define': 0,
'@typescript-eslint/no-use-before-define': 2,
'no-shadow': 0,
'@typescript-eslint/no-shadow': [2, { ignoreTypeValueShadow: true }],
// https://github.com/typescript-eslint/typescript-eslint/issues/2528#issuecomment-689369395
'no-undef': 0,
},
};

module.exports = eslintrc;
124 changes: 124 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: HankLiu UI Components Publish

on:
push:
branches:
# 触发ci/cd的代码分支
- master

jobs:
setup:
# 指定操作系统
runs-on: ubuntu-latest
steps:
# 将代码拉到虚拟机
- name: 获取源码 🛎️
uses: actions/checkout@v2
# 指定node版本
- name: Node环境版本 🗜️
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: 获取lock文件 🎻
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

# 仅在不下载任何包的情况下,更新package-lock.json文件。
# 这个命令常用于确保所有的依赖项都是最新的,或者在你不确定更新了哪些包时刷新锁文件。
- name: 更新lock文件 📌
run: npm i --package-lock-only

# 缓存lock文件到package-temp-dir路径
- name: 缓存lock文件 🗼
run: |
if [ ! -d "package-temp-dir" ]; then
mkdir package-temp-dir
fi
cp package-lock.json package-temp-dir
# 依赖缓存策略
- name: Npm缓存 📁
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

# 依赖下载
- name: 安装依赖 📦
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci

compile:
runs-on: ubuntu-latest
steps:
# 将代码拉到虚拟机
- name: 获取源码 🛎️
uses: actions/checkout@v2

# 获取或存的lock文件
- name: 获取lock文件 🎻
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

# 依赖缓存策略
- name: Npm缓存 📁
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

# 打包
- name: 打包 🏗️
run: npm run compile

# 发布
- name: 发布 🚀
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

needs: setup

site:
runs-on: ubuntu-latest
steps:
# 将代码拉到虚拟机
- name: 获取源码 🛎️
uses: actions/checkout@v2

# 获取或存的lock文件
- name: 获取lock文件 🎻
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

# 依赖缓存策略
- name: Npm缓存 📁
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

# 生成文档
- name: 生成文档 🍚
run: npm run site && touch ./_site/.nojekyll # run: touch ./_website/.nojekyll是因为由于 Jekyll 处理,GitHub 默认不提供_next文件夹,.nojekyll文件阻止了这种情况,

- name: 部署 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # 部署后提交到那个分支
folder: _site # 这里填打包好的目录名称
clean: true

needs: setup
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.vscode/
.idea/
.history/

/coverage
node_modules/
npm-debug.log
yarn.lock

.DS_Store
Thumbs.db

_site
_data
dist
report.html
es/
lib/
yarn-debug.log*
yarn-error.log*
33 changes: 33 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
site

components

docs

scripts

.editorconfig

.eslintrc.js

.gitignore

.npmrc

.prettierignore

.stylelintrc.json

CHANGELOG.zh-CN.md

UPDATE.zh-CN.md

pnpm-lock.yaml

tsconfig.json

webpack.config.js

_website

_site
Empty file added .npmrc
Empty file.
27 changes: 27 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
**/*.svg
package.json
.umi
.umi-production
AUTHORS.txt
lib/
es/
dist/
_site/
coverage/
CNAME
LICENSE
yarn.lock
netlify.toml
yarn-error.log
*.sh
*.snap
components/*/*.js
components/*/*.jsx
.gitignore
.npmignore
.prettierignore
.DS_Store
.editorconfig
.eslintignore
**/*.yml
components/style/color/*.less
Loading

0 comments on commit 19acb5a

Please sign in to comment.