diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..ee82116646 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +max_line_length = 120 +trim_trailing_whitespace = true +indent_style = tab +indent_size = 4 + +[*.yml] +indent_style = space +indent_size = 2 + +[*.pg] +trim_trailing_whitespace = false diff --git a/.github/workflows/check-formats.yml b/.github/workflows/check-formats.yml new file mode 100644 index 0000000000..ec47d6c741 --- /dev/null +++ b/.github/workflows/check-formats.yml @@ -0,0 +1,44 @@ +--- +name: Check Formatting of Code Base + +defaults: + run: + shell: bash + +on: + push: + branches-ignore: [main, develop] + pull_request: + +jobs: + perltidy: + name: Check Perl file formatting with perltidy + runs-on: ubuntu-22.04 + container: + image: perl:5.34 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install dependencies + run: cpanm -n Perl::Tidy@20220613 + - name: Run perltidy + shell: bash + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + shopt -s extglob globstar nullglob + perltidy --pro=./.perltidyrc -b -bext='/' ./**/*.p[lm] ./**/*.t && git diff --exit-code + + prettier: + name: Check JavaScript, style, and HTML file formatting with prettier + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install Dependencies + run: cd htdocs && npm ci --ignore-scripts + - name: Check formatting with prettier + run: cd htdocs && npm run prettier-check diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index f4ff1e90d3..0000000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Lint Code Base - -defaults: - run: - shell: bash - -on: - push: - branches-ignore: [main, develop] - pull_request: - -jobs: - perltidy: - name: Run perltidy on Perl Files - runs-on: ubuntu-22.04 - container: - image: perl:5.34 - steps: - - uses: actions/checkout@v3 - - name: perl -V - run: perl -V - - name: Install dependencies - run: cpanm -n Perl::Tidy@20220613 - - name: perltidy --version - run: perltidy --version - - name: Run perltidy - shell: bash - run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" - shopt -s extglob globstar nullglob - perltidy --pro=./.perltidyrc -b -bext='/' ./**/*.p[lm] ./**/*.t && git diff --exit-code diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..b21dab0657 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "arrowParens": "always", + "bracketSpacing": true, + "printWidth": 120, + "semi": true, + "singleQuote": true, + "trailingComma": "none" +} diff --git a/htdocs/package-lock.json b/htdocs/package-lock.json index 28ebb0033b..9caff05ca4 100644 --- a/htdocs/package-lock.json +++ b/htdocs/package-lock.json @@ -24,6 +24,7 @@ "chokidar": "^3.5.3", "cssnano": "^6.0.1", "postcss": "^8.4.31", + "prettier": "^3.1.1", "rtlcss": "^4.1.1", "sass": "^1.69.5", "terser": "^5.24.0", @@ -1370,6 +1371,21 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", "dev": true }, + "node_modules/prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -2544,6 +2560,12 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", "dev": true }, + "prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true + }, "readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", diff --git a/htdocs/package.json b/htdocs/package.json index 13ef2aabea..056dbb9dbb 100644 --- a/htdocs/package.json +++ b/htdocs/package.json @@ -4,7 +4,9 @@ "license": "GPL-2.0+", "scripts": { "generate-assets": "node generate-assets", - "prepare": "npm run generate-assets" + "prepare": "npm run generate-assets", + "prettier-format": "prettier --ignore-path=../.gitignore --write \"**/*.{js,css,scss,html}\"", + "prettier-check": "prettier --ignore-path=../.gitignore --check \"**/*.{js,css,scss,html}\"" }, "repository": { "type": "git", @@ -28,6 +30,7 @@ "chokidar": "^3.5.3", "cssnano": "^6.0.1", "postcss": "^8.4.31", + "prettier": "^3.1.1", "rtlcss": "^4.1.1", "sass": "^1.69.5", "terser": "^5.24.0",