Skip to content

Commit

Permalink
Merge pull request #1 from DimensionDev/chore/setup
Browse files Browse the repository at this point in the history
chore: setup the proj
  • Loading branch information
guanbinrui authored Mar 6, 2024
2 parents 58364f7 + 5352bcc commit 39548cc
Show file tree
Hide file tree
Showing 125 changed files with 16,066 additions and 5,095 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 4
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
next.config.js
lingui.config.js
postcss.config.cjs
tailwind.config.cjs

src/locales/**/*.mjs
public/js
179 changes: 178 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,180 @@
{
"extends": "next/core-web-vitals"
"extends": "next/core-web-vitals",
"plugins": [
"no-relative-import-paths",
"eslint-plugin-simple-import-sort",
"@typescript-eslint/eslint-plugin",
"eslint-plugin-react",
"eslint-plugin-react-hooks",
"eslint-plugin-unicorn",
"eslint-plugin-import",
"unused-imports"
],
"rules": {
"default-case-last": "error",
"eqeqeq": "error",
"import/no-empty-named-blocks": "warn",
"import/no-named-default": "warn",
"import/no-useless-path-segments": "warn",
"import/no-webpack-loader-syntax": "error",
"no-bitwise": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-constant-binary-expression": "error",
"no-constant-condition": "warn",
"no-constructor-return": "error",
"no-control-regex": "error",
"no-debugger": "warn",
"no-div-regex": "error",
"no-duplicate-case": "error",
"no-empty-character-class": "error",
"no-empty-pattern": "warn",
"no-ex-assign": "warn",
"no-extra-bind": "warn",
"no-extra-boolean-cast": "warn",
"no-extra-label": "warn",
"no-global-assign": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": "warn",
"no-label-var": "error",
"no-misleading-character-class": "error",
"no-new-wrappers": "error",
"no-plusplus": "error",
"no-regex-spaces": "error",
"no-restricted-globals": ["error", "event", "name", "length", "closed"],
"no-restricted-imports": [
"error",
{
"patterns": ["src/maskbook/*", "@/maskbook/*"]
}
],
"no-script-url": "error",
"no-self-assign": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "warn",
"no-unreachable-loop": "error",
"no-unsafe-finally": "error",
"no-unused-labels": "warn",
"no-unused-vars": "off",
"no-useless-backreference": "error",
"no-useless-call": "warn",
"no-useless-catch": "warn",
"no-useless-concat": "warn",
"no-useless-escape": "warn",
"object-shorthand": "warn",
"prefer-const": "warn",
"prefer-numeric-literals": "warn",
"prefer-object-has-own": "warn",
"prefer-regex-literals": "warn",
"radix": "warn",
"spaced-comment": ["warn", "always", { "line": { "markers": ["/"] } }],
"unused-imports/no-unused-imports": "error",
"valid-typeof": "error",
"yoda": "warn",
"react/jsx-no-comment-textnodes": "warn",
"react/jsx-no-leaked-render": "error",
"react/jsx-no-script-url": "error",
"react/no-danger": "error",
"react/no-danger-with-children": "error",
"react/no-namespace": "error",
"react/no-unstable-nested-components": "error",
"react/void-dom-elements-no-children": "error",
"react/no-invalid-html-attribute": "warn",
"react/jsx-key": [
"warn",
{ "checkFragmentShorthand": true, "checkKeyMustBeforeSpread": true, "warnOnDuplicates": true }
],
"react/jsx-no-constructed-context-values": "warn",
"react/no-deprecated": "error",
"react/no-find-dom-node": "error",
"react/function-component-definition": [
"warn",
{
"namedComponents": "function-declaration",
"unnamedComponents": ["function-expression", "arrow-function"]
}
],
"react/jsx-boolean-value": ["error", "never"],
"react/self-closing-comp": ["error", { "component": true, "html": true }],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"{}": false,
"FC": {
"message": "To declare a component, you don't have to use FC to annotate it. To type something that accepts/is a React Component, use ComponentType<T>.",
"fixWith": "ComponentType"
},
"ReactElement": {
"message": "In most cases, you want ReactNode. Only ignore this rule when you want to use cloneElement.",
"fixWith": "ReactNode"
},
"React.FC": {
"message": "To declare a component, you don't have to use React.FC to annotate it. To type something that accepts/is a React Component, use React.ComponentType<T>.",
"fixWith": "React.ComponentType"
},
"React.ReactElement": {
"message": "In most cases, you want React.ReactNode. Only ignore this rule when you want to use cloneElement.",
"fixWith": "React.ReactNode"
}
},
"extendDefaults": true
}
],
"@typescript-eslint/array-type": ["warn", { "default": "array-simple" }],
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/consistent-type-assertions": ["warn", { "assertionStyle": "as" }],
"@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/no-array-constructor": "warn",
"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-extra-non-null-assertion": "warn",
"@typescript-eslint/no-for-in-array": "warn",
"@typescript-eslint/no-implied-eval": "error",
"@typescript-eslint/no-loop-func": "warn",
"@typescript-eslint/no-loss-of-precision": "error",
"@typescript-eslint/no-meaningless-void-operator": "warn",
"@typescript-eslint/no-mixed-enums": "error",
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "warn",
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "error",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/prefer-enum-initializers": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/prefer-literal-enum-member": "error",
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
"@typescript-eslint/prefer-return-this-type": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/no-misused-new": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"no-relative-import-paths/no-relative-import-paths": [
"warn",
{
"prefix": "@",
"rootDir": "src"
}
]
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"project": "./tsconfig.eslint.json",
"warnOnUnsupportedTypeScriptVersion": false,
"allowAutomaticSingleRunInference": true
}
}
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Pull Request

## Description

<!-- Provide a brief description of the changes introduced by this pull request -->

## Related Issue

Closes SW-0000

<!-- Find your issue from: https://mask.atlassian.net/jira/software/c/projects/FW/boards/33/backlog -->

## Checklist

- [ ] I have tested these changes locally.
- [ ] I have reviewed the code changes.
- [ ] I have added unit tests if applicable.
22 changes: 22 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Conventional Commits"

on:
pull_request:
types:
- opened
- edited
- synchronize
branches:
- "!sync-submodule-changes"
- "!l10n_crowdin_action"

jobs:
main:
name: validate
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
wip: true
32 changes: 32 additions & 0 deletions .github/workflows/crowdin-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Crowdin Download

on:
schedule:
- cron: '0 0 * * *' # every day at 00:00 (midnight)
- cron: '0 12 * * *' # every day at 12:00 PM (noon)

# start via Actions tab in Github UI
workflow_dispatch:

jobs:
download-translations:
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Download from Crowdin
uses: crowdin/github-action@v1
with:
upload_translations: false
download_translations: true
create_pull_request: true
pull_request_body: 'FW-0000'
pull_request_base_branch_name: 'main'
pull_request_labels: 'automated'
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/crowdin-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Crowdin Upload

on:
push:
branches:
- main

# start via Actions tab in Github UI
workflow_dispatch:

jobs:
upload-translations:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

# all locales must be extracted before upload on the main branch
- name: Upload to Crowdin
uses: crowdin/github-action@v1
with:
upload_translations: true
download_translations: false
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CSpell

on:
push:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Authenticate NPM
uses: DimensionDev/github-token-action@latest
with:
registry: true

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.9.0'

- uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install

- name: Run CSpell
run: npx cspell "**/*"
41 changes: 41 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ESLint

on:
push:
branches:
- '**'
- '!main'
- '!released'
jobs:
eslint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Authenticate NPM
uses: DimensionDev/github-token-action@latest
with:
registry: true

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.9.0'

- uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install

- name: Run ESLint
run: npx eslint --fix .

- name: Check for changes in src/*
id: check-changes
run: echo "::set-output name=changes::$(git diff --name-only -- 'src/*')"

- name: Commit changes if any
uses: EndBug/add-and-commit@v9
with:
message: 'chore: eslint'
Loading

0 comments on commit 39548cc

Please sign in to comment.