generated from amattu2/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement ESLint and Prettier (#179)
* Rewrite GitHub Actions as separate Lint, Test, and Typecheck jobs * Fix broken ESLint setup and integrate with Prettier * Run formatter and apply auto-fixes
- Loading branch information
Showing
122 changed files
with
18,475 additions
and
30,303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* @type {import("eslint").Linter.Config} | ||
*/ | ||
const config = { | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"airbnb", | ||
"airbnb-typescript", | ||
"prettier", | ||
"react-app", | ||
"react-app/jest", | ||
], | ||
globals: { | ||
window: true, | ||
document: true, | ||
}, | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
ecmaVersion: 11, | ||
project: "./tsconfig.json", | ||
sourceType: "module", | ||
}, | ||
plugins: ["react", "@typescript-eslint", "prettier"], | ||
settings: { | ||
react: { | ||
pragma: "React", | ||
fragment: "Fragment", | ||
version: "detect", | ||
}, | ||
}, | ||
root: true, | ||
rules: { | ||
/* base prettier rule */ | ||
"prettier/prettier": "error", | ||
|
||
"max-len": "off", | ||
"no-console": "warn", | ||
"no-param-reassign": "off", | ||
"object-curly-newline": "off", | ||
"no-underscore-dangle": ["off"], | ||
"arrow-body-style": ["warn"], | ||
"eol-last": ["warn"], | ||
"no-unreachable": ["warn"], | ||
"no-continue": "off", | ||
|
||
/* typescript-eslint overwritten rules */ | ||
"no-use-before-define": "off", | ||
"no-unused-vars": "off", | ||
"no-loss-of-precision": "off", | ||
"no-shadow": "off", | ||
"no-empty-function": "off", | ||
|
||
/* react rules */ | ||
"react/prop-types": "off", | ||
"react/jsx-filename-extension": [1, { extensions: [".js", ".jsx", ".tsx", ".ts"] }], | ||
"react/jsx-props-no-spreading": "off", | ||
"react/react-in-jsx-scope": "off", | ||
"react/require-default-props": "off", | ||
"react/jsx-max-props-per-line": [1, { maximum: 1, when: "multiline" }], | ||
"react/function-component-definition": [ | ||
"error", | ||
{ | ||
namedComponents: "arrow-function", | ||
unnamedComponents: "arrow-function", | ||
}, | ||
], | ||
"react/jsx-key": [ | ||
"error", | ||
{ | ||
checkFragmentShorthand: true, | ||
checkKeyMustBeforeSpread: true, | ||
warnOnDuplicates: true, | ||
}, | ||
], | ||
"react/destructuring-assignment": ["error", "always", { destructureInSignature: "always" }], | ||
|
||
/* typescript-eslint rules */ | ||
"@typescript-eslint/no-empty-function": "error", | ||
"@typescript-eslint/no-use-before-define": "error", | ||
"@typescript-eslint/no-unused-vars": "warn", | ||
"@typescript-eslint/no-loss-of-precision": "error", | ||
"@typescript-eslint/no-redundant-type-constituents": "error", | ||
"@typescript-eslint/no-non-null-asserted-optional-chain": "error", | ||
"@typescript-eslint/no-shadow": "off", | ||
"@typescript-eslint/dot-notation": "off", | ||
"@typescript-eslint/naming-convention": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
|
||
/* create-react-app rules */ | ||
"react-hooks/exhaustive-deps": "off", | ||
"import/prefer-default-export": "off", | ||
"import/no-extraneous-dependencies": ["error", { devDependencies: true }], | ||
|
||
/* jest and testing-library rules */ | ||
"testing-library/prefer-screen-queries": "off", | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CodeQL | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
- "master" | ||
- "dev" | ||
- "development" | ||
pull_request: | ||
branches: "*" | ||
schedule: | ||
- cron: '16 23 * * 4' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze (${{ matrix.language }}) | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 360 | ||
permissions: | ||
security-events: write | ||
packages: read | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- language: javascript-typescript | ||
build-mode: none | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
build-mode: ${{ matrix.build-mode }} | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: ESLint | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
- "master" | ||
- "dev" | ||
- "development" | ||
pull_request: | ||
branches: "*" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
name: Lint Changes | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
cache: "npm" | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-modules- | ||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Run ESLint | ||
run: npm run lint:ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Jest | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
- "master" | ||
- "dev" | ||
- "development" | ||
pull_request: | ||
branches: "*" | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
name: Test Changes | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
cache: "npm" | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-modules- | ||
- name: Install Dependencies | ||
run: npm install | ||
|
||
- name: Run Jest | ||
run: npm run test:ci | ||
|
||
- name: Coveralls GitHub Action | ||
uses: coverallsapp/[email protected] |
Oops, something went wrong.