Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint - The Essential Linter and Formatter for JavaScript and TypeScript #1224

Merged
merged 36 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
616f011
eslint config + packages
Greenlamp2 May 21, 2024
da9b59c
updated eslint config
Greenlamp2 May 21, 2024
8eb6f8a
fix the issue eslint adding ;;;; at interfaces
Greenlamp2 May 21, 2024
77a88e0
first round with eslint --fix .
Greenlamp2 May 21, 2024
7633b4e
removed config for unused export
Greenlamp2 May 21, 2024
164f292
Revert "first round with eslint --fix ."
Greenlamp2 May 21, 2024
dc82cdb
removed config for camelCase
Greenlamp2 May 21, 2024
28ada38
for real this time, first round of eslint --fix .
Greenlamp2 May 21, 2024
8e25060
halfway to manual eslint fix
Greenlamp2 May 21, 2024
9a8b604
eslint done
Greenlamp2 May 21, 2024
78f8abc
added "how to setup" the hook to eslint --fix each new file before co…
Greenlamp2 May 22, 2024
ebb7a81
removed eslintrc config file duplicat
Greenlamp2 May 22, 2024
1672206
fix human error + ignore build folder + merge overrides
Greenlamp2 May 22, 2024
b0371fc
added curly brace style + eslint
Greenlamp2 May 22, 2024
c5963a2
Merge branch 'main' of github.com:pagefaultgames/pokerogue into feat/…
Greenlamp2 May 22, 2024
f7baca1
Merge branch 'main-pokerogue' into feat/eslint
f-fsantos May 23, 2024
be1e15a
applied double quote linter rule
f-fsantos May 23, 2024
0879f60
Merge branch 'feat/eslint' of github.com:Greenlamp2/pokerogue into fe…
Greenlamp2 May 23, 2024
75cb018
added lefthook
Greenlamp2 May 23, 2024
b9eadd0
test precommit
Greenlamp2 May 23, 2024
94a5f0e
test precommit
Greenlamp2 May 23, 2024
ae6800d
test precommit
Greenlamp2 May 23, 2024
dee00be
test precommit
Greenlamp2 May 23, 2024
d376737
test precommit
Greenlamp2 May 23, 2024
cd6be50
test precommit
Greenlamp2 May 23, 2024
a6f1c3e
test precommit
Greenlamp2 May 23, 2024
21e2551
github action to run eslint
Greenlamp2 May 23, 2024
00d7301
added node_modules to ignore eslint
Greenlamp2 May 23, 2024
5cd26a6
different action for typescript
Greenlamp2 May 23, 2024
c501e20
no need for different glob (default src)
Greenlamp2 May 23, 2024
1c9cf41
node 20
Greenlamp2 May 23, 2024
ac41fb3
node 20
Greenlamp2 May 23, 2024
a07e6b3
removed no longer needed install file
Greenlamp2 May 23, 2024
54151c6
remove hooks part from README
Greenlamp2 May 23, 2024
2e6f1fa
Merge branch 'main-pokerogue' into feat/eslint
f-fsantos May 23, 2024
eafae6b
eslint fixes
f-fsantos May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dist/*
build/*
coverage/*
public/*
.github/*
node_modules/*
.vscode/*
42 changes: 27 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
{
"env": {
"browser": true,
"es2021": true
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"overrides": [
{
"files": ["src/**/*.ts"],
"extends": "eslint:recommended"
}
],
"rules": {}
"parser": "@typescript-eslint/parser", // Specifies the ESLint parser for TypeScript
"plugins": ["@typescript-eslint", "import"], // Includes TypeScript and import plugins
"overrides": [
{
"files": ["src/**/*.{ts,tsx,js,jsx}"], // Applies these rules to all TypeScript and JavaScript files in the src directory
"rules": {
// General rules that apply to all files
"eqeqeq": ["error", "always"], // Enforces the use of === and !== instead of == and !=
"indent": ["error", 2], // Enforces a 2-space indentation
"quotes": ["error", "double"], // Enforces the use of double quotes for strings
"no-var": "error", // Disallows the use of var, enforcing let or const instead
"prefer-const": "error", // Prefers the use of const for variables that are never reassigned
"no-undef": "off", // Disables the rule that disallows the use of undeclared variables (TypeScript handles this)
"@typescript-eslint/no-unused-vars": [ "error", {
"args": "none", // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used.
"ignoreRestSiblings": true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the rest.
}],
"eol-last": ["error", "always"], // Enforces at least one newline at the end of files
"@typescript-eslint/semi": ["error", "always"], // Requires semicolons for TypeScript-specific syntax
"semi": "off", // Disables the general semi rule for TypeScript files
"@typescript-eslint/no-extra-semi": ["error"], // Disallows unnecessary semicolons for TypeScript-specific syntax
"brace-style": "off", // Note: you must disable the base rule as it can report incorrect errors
"curly": ["error", "all"], // Enforces the use of curly braces for all control statements
"@typescript-eslint/brace-style": ["error", "1tbs"]
}
}
]
}
31 changes: 31 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ESLint

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main # Trigger on push events to the main branch
pull_request:
branches:
- main # Trigger on pull request events targeting the main branch

jobs:
run-linters: # Define a job named "run-linters"
name: Run linters # Human-readable name for the job
runs-on: ubuntu-latest # Specify the latest Ubuntu runner for the job

steps:
- name: Check out Git repository # Step to check out the repository
uses: actions/checkout@v2 # Use the checkout action version 2

- name: Set up Node.js # Step to set up Node.js environment
uses: actions/setup-node@v1 # Use the setup-node action version 1
with:
node-version: 20 # Specify Node.js version 20

- name: Install Node.js dependencies # Step to install Node.js dependencies
run: npm ci # Use 'npm ci' to install dependencies

- name: eslint # Step to run linters
uses: icrawl/action-eslint@v1
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ If you have the motivation and experience with Typescript/Javascript (or are wil
- *if you run into any errors, reach out in the **#dev-corner** channel in discord*
2. Run `npm run start:dev` to locally run the project in `localhost:8000`

## Setting Up Git Hooks

After cloning the repository, run the following command to set up the pre-commit hook:

```sh
./setup-hooks.sh
```

This will run npx eslint --fix XXX where XXX is each file in your commit
Greenlamp2 marked this conversation as resolved.
Show resolved Hide resolved
### ❔ FAQ

**How do I test a new _______?**
Expand Down
7 changes: 7 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pre-commit:
parallel: true
commands:
eslint:
glob: '*.{js,jsx,ts,tsx}'
run: npx eslint --fix {staged_files}
stage_fixed: true
Loading
Loading