diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml new file mode 100644 index 0000000..4fa815e --- /dev/null +++ b/.github/workflows/code-style.yml @@ -0,0 +1,45 @@ +name: Code Style + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v2.3.0 + with: + commit_message: Fix styling + branch: main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + prettier: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install NPM dependencies + run: npm ci + + - name: Run Prettier + run: npm run format + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v2.3.0 + with: + commit_message: Apply Prettier changes + branch: main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index e70b076..a4842ed 100755 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ bios/** saves/** screenshots/** .DS_Store -.env \ No newline at end of file +.env +node_modules diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..b2adc48 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,42 @@ +setRules([ + '@PSR2' => true, + 'concat_space' => ['spacing' => 'one'], + 'no_unused_imports' => true, + 'whitespace_after_comma_in_array' => true, + 'method_argument_space' => [ + 'keep_multiple_spaces_after_comma' => true, + 'on_multiline' => 'ignore' + ], + 'return_type_declaration' => [ + 'space_before' => 'none' + ], + // only converts simple strings in double quotes to single quotes + // ignores strings using variables, escape characters or single quotes inside + 'single_quote' => true, + // there should be a single space b/w the cast and it's operand + 'cast_spaces' => ['space' => 'single'], + // there shouldn't be any trailing whitespace at the end of a non-blank line + 'no_trailing_whitespace' => true, + // there shouldn't be any trailing whitespace at the end of a blank line + 'no_whitespace_in_blank_line' => true, + // there should be a space around binary operators like (=, => etc) + 'binary_operator_spaces' => ['default' => 'single_space'], + // deals with rogue empty blank lines + 'no_extra_blank_lines' => ['tokens' => ['extra']], + // reduces multi blank lines b/w phpdoc description and @param to a single line + // NOTE: Doesn't add a blank line if none exist + 'phpdoc_trim_consecutive_blank_line_separation' => true, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__) + ) +; + +return $config; diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..483b4af --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +emu diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..329a957 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,27 @@ +{ + "name": "CalypsDoH", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "prettier": "3.2.5" + } + }, + "node_modules/prettier": { + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3cc559b --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "prettier": "3.2.5" + }, + "scripts": { + "format": "prettier . --write --ignore-unknown" + } +}