Skip to content

Commit

Permalink
chore: enforce prettier and eslint (#3014)
Browse files Browse the repository at this point in the history
See issue #2378 

- Add prettier for code formatting
- Update eslint config to parse other parts of codebase outside of `src/engine`, and also remove rules that are handled by prettier
- Add husky & lint-staged to enforce formatting on git commit
- Add format step to `all` and `all:ci` scripts

I separated the commit that runs the format & lint on all files into #3015 so the config can be easily reviewed here. 

Once we're happy with this, we can merge that PR into this one and ignore the commit(s) using `git blame --ignore-rev` to remove it from git blame history.
  • Loading branch information
mattjennings authored Apr 8, 2024
1 parent dd1b2eb commit 582fbcc
Show file tree
Hide file tree
Showing 474 changed files with 11,224 additions and 4,895 deletions.
2 changes: 1 addition & 1 deletion .babelrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"@babel/preset-typescript"
],
"plugins": []
}
}
16 changes: 11 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
site/
scripts/apidocs.js
scripts/release.js
karma.conf.js
/site
/sandbox
/scripts
karma.conf.*
webpack.config.js
webpack.config.prod.js
version.js
wallaby.js
version.js
node_modules
build
coverage
node_cache
*.d.ts
118 changes: 32 additions & 86 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,88 +3,65 @@
"browser": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./src/**/tsconfig.json"
],
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"jsdoc"
],
"extends": [
"plugin:jsdoc/recommended",
"prettier",
"plugin:storybook/recommended"
"plugins": ["@typescript-eslint", "jsdoc"],
"extends": ["plugin:jsdoc/recommended", "plugin:storybook/recommended", "prettier"],
"overrides": [
// javascript parser
{
"files": ["*.js", "*.jsx"],
// we can still use the typescript parser for javascript files
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": false
}
},
// typescript parser
{
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": true
}
}
],
"rules": {
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "class",
"format": [
"PascalCase"
]
"format": ["PascalCase"]
},
{
"selector": "memberLike",
"modifiers": [
"private",
"static"
],
"format": [
"UPPER_CASE"
],
"modifiers": ["private", "static"],
"format": ["UPPER_CASE"],
"leadingUnderscore": "require"
},
{
"selector": "memberLike",
"modifiers": [
"private"
],
"format": [
"camelCase"
],
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": "interface",
"format": [
"PascalCase"
],
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": false
}
}
],
"@typescript-eslint/indent": [
"error",
2
],
"@typescript-eslint/no-empty-function": "error",
"curly": "error",
"dot-notation": "error",
"no-caller": "error",
"no-console": [
"error",
{
"allow": [
"debug",
"info",
"time",
"timeEnd",
"trace"
]
}
],
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
"allow": ["debug", "info", "time", "timeEnd", "trace"]
}
],
"no-debugger": "error",
Expand All @@ -97,37 +74,15 @@
"prefer-const": "error",
"require-await": "warn",
"radix": "error",
"max-len": [
"error",
{
"code": 140
}
],
"semi": [
"error",
"always"
],
"comma-dangle": [
"error",
"never"
],
"no-trailing-spaces": "error",
"eqeqeq": [
"error",
"smart"
],
"eqeqeq": ["error", "smart"],
"no-irregular-whitespace": "error",
"brace-style": [
"error",
"1tbs"
],
"brace-style": ["error", "1tbs"],
"no-unused-expressions": [
"error",
{
"allowTernary": true
}
],
"keyword-spacing": "error",
"jsdoc/require-param": 0,
"jsdoc/require-param-description": 0,
"jsdoc/require-param-type": 0,
Expand All @@ -138,16 +93,7 @@
"jsdoc/check-tag-names": [
"error",
{
"definedTags": [
"hidden",
"internal",
"source",
"obsolete",
"warning",
"notimplemented",
"credit",
"typedoc"
]
"definedTags": ["hidden", "internal", "source", "obsolete", "warning", "notimplemented", "credit", "typedoc"]
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
9223608d57af6efe3205baa924c16b8f4788bd5b
3cf93825d0a90e93651f058bfd200df0c43f47db
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: Excalibur Discord Link
url: https://discord.gg/W6zUd4tTY3
about: Join the Excalibur Discord and come chat about making video games!
about: Join the Excalibur Discord and come chat about making video games!
2 changes: 1 addition & 1 deletion .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
enhancement: ['feature/*', 'feat/*', 'enhancement/*']
bug: ['fix/*', 'bug/*']
chore: chore/*
chore: chore/*
24 changes: 12 additions & 12 deletions .github/workflows/browsersupport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ env:
BS_PASSWORD: ${{ secrets.BS_PASSWORD }}
on:
push:
branches: [ main ]
branches: [main]
jobs:
browser_support:
runs-on: [ubuntu-latest]
timeout-minutes: 15

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm ci
- run: npm run browserstack
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm ci
- run: npm run browserstack
89 changes: 44 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,69 @@ name: CI

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: "${{ secrets.COVERALLS_REPO_TOKEN }}"
COVERALLS_GIT_BRANCH: "${{ github.ref }}"
COVERALLS_REPO_TOKEN: '${{ secrets.COVERALLS_REPO_TOKEN }}'
COVERALLS_GIT_BRANCH: '${{ github.ref }}'

on:
pull_request:
branches: [ main ]
branches: [main]
push:
branches: [ main ]
branches: [main]
workflow_call:

jobs:
build:
runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm ci
- run: npm run linux:ci
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm ci
- run: npm run linux:ci
- name: Coveralls
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

typedoc:
runs-on: [ubuntu-latest]
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
- run: npm run apidocs
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
- run: npm run apidocs

examples:
runs-on: [ubuntu-latest]
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
- run: npm run build-storybook

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 100
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
- run: npm run build-storybook
Loading

0 comments on commit 582fbcc

Please sign in to comment.