Skip to content

Commit

Permalink
refactor: 参考alloy 重构
Browse files Browse the repository at this point in the history
  • Loading branch information
eyea committed Dec 6, 2023
1 parent 80e5171 commit 2ed9475
Show file tree
Hide file tree
Showing 1,218 changed files with 20,455 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
site/public
21 changes: 14 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"use strict";
// "use strict";

// module.exports = {
// root: true,
// extends: [
// "eslint:recommended",
// ],
// env: {
// node: true,
// },
// };

module.exports = {
root: true,
extends: [
"eslint:recommended",
],
env: {
node: true,
extends: ['./index.js', './react.js', './typescript.js'],
globals: {
Prism: false,
},
};
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: '16'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test

- name: Build gh-pages
run: pnpm build

- name: Deploy gh-pages
if: |
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
34 changes: 34 additions & 0 deletions .github/workflows/rulesCoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: rulesCoverage

on:
schedule:
# Runs on every Monday 18:00
- cron: '0 18 * * 1'
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: '16'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: |
pnpm test &&
pnpm rulesCoverage
31 changes: 31 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## OS
.DS_Store
.idea
.editorconfig
pnpm-lock.yaml
.npmrc

# Ignored suffix
*.log
*.md
*.svg
*.png
*.ico
*ignore

## Local
site/public
test/base/no-cond-assign/bad.js
test/base/no-irregular-whitespace/bad.js
test/base/no-labels/bad.js
test/base/no-sequences/bad.js
test/base/no-useless-rename/bad.js
test/react/jsx-fragments/bad.js
test/react/self-closing-comp/bad.js
test/vue/no-irregular-whitespace/bad.vue
test/vue/no-irregular-whitespace/good.vue
.husky

## Built-files
.cache
dist
44 changes: 44 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// .prettierrc.js
module.exports = {
// 一行最多 120 字符
printWidth: 120,
// 使用 2 个空格缩进
tabWidth: 2,
// 不使用缩进符,而使用空格
useTabs: false,
// 行尾需要有分号
semi: true,
// 使用单引号
singleQuote: true,
// 对象的 key 仅在必要时用引号
quoteProps: 'as-needed',
// jsx 不使用单引号,而使用双引号
jsxSingleQuote: false,
// 末尾需要有逗号
trailingComma: 'all',
// 大括号内的首尾需要空格
bracketSpacing: true,
// jsx 标签的反尖括号需要换行
bracketSameLine: false,
// 箭头函数,只有一个参数的时候,也需要括号
arrowParens: 'always',
// 每个文件格式化的范围是文件的全部内容
rangeStart: 0,
rangeEnd: Infinity,
// 不需要写文件开头的 @prettier
requirePragma: false,
// 不需要自动在文件开头插入 @prettier
insertPragma: false,
// 使用默认的折行标准
proseWrap: 'preserve',
// 根据显示样式决定 html 要不要折行
htmlWhitespaceSensitivity: 'css',
// vue 文件中的 script 和 style 内不用缩进
vueIndentScriptAndStyle: false,
// 换行符使用 lf
endOfLine: 'lf',
// 格式化嵌入的内容
embeddedLanguageFormatting: 'auto',
// html, vue, jsx 中每个属性占一行
singleAttributePerLine: false,
};
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ npm i @afuteam/eslint-plugin-fe@latest -D
}
```

## TODO

### 增加测试用例

### 组合方式:

1. [ ] vue2 + ts
2. [ ] vue3 + ts
3. [ ] react + ts
4. [ ] react
5. [ ] vue2
6. [ ] vue3
7. [ ] ts
8. [ ] js
Loading

0 comments on commit 2ed9475

Please sign in to comment.