Skip to content

Commit e5fb141

Browse files
Copilotmartinemde
andcommitted
Add JavaScript linting with Prettier configuration
Co-authored-by: martinemde <[email protected]>
1 parent 8b172d4 commit e5fb141

7 files changed

Lines changed: 111 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ jobs:
4444
bundler-cache: true
4545
- name: Importmap Verify
4646
run: bundle exec rake importmap:verify
47+
prettier:
48+
name: Prettier
49+
runs-on: ubuntu-24.04
50+
steps:
51+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
52+
with:
53+
persist-credentials: false
54+
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
55+
with:
56+
node-version: '20'
57+
cache: 'npm'
58+
- name: Install dependencies
59+
run: npm ci
60+
- name: Check JavaScript formatting
61+
run: npm run lint:js
4762
kubeconform:
4863
name: Kubeconform
4964
runs-on: ubuntu-24.04

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ REVISION
2828
/doc/erd.*
2929
/app/assets/builds/*
3030
!/app/assets/builds/.keep
31+
node_modules/

.prettierignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build outputs
5+
public/assets/
6+
vendor/
7+
8+
# Temporary files
9+
tmp/
10+
11+
# Test reports
12+
reports/
13+
14+
# Log files
15+
*.log
16+
17+
# Lock files
18+
package-lock.json
19+
yarn.lock

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": false,
7+
"quoteProps": "as-needed",
8+
"trailingComma": "es5",
9+
"bracketSpacing": true,
10+
"bracketSameLine": false,
11+
"arrowParens": "always"
12+
}

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ can try running:
159159

160160
bundle exec rake rubocop:autocorrect
161161

162+
#### Running JavaScript Formatting
163+
164+
We use Prettier to enforce consistent JavaScript code style throughout the project.
165+
Please ensure any JavaScript changes conform to our style standards or else the
166+
build will fail.
167+
168+
Check JavaScript formatting:
169+
170+
npm run lint:js
171+
172+
To automatically fix JavaScript formatting issues:
173+
174+
npm run format
175+
162176
#### Importing gems into the database
163177

164178
* Import gems into the database with Rake task.

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "rubygems-org",
3+
"version": "1.0.0",
4+
"description": "JavaScript tooling for RubyGems.org",
5+
"private": true,
6+
"scripts": {
7+
"format": "npx prettier --write 'app/javascript/**/*.js' 'config/*.js'",
8+
"lint:js": "npx prettier --check 'app/javascript/**/*.js' 'config/*.js'"
9+
},
10+
"devDependencies": {
11+
"prettier": "^3.0.0"
12+
},
13+
"engines": {
14+
"node": ">=18.0.0"
15+
}
16+
}

0 commit comments

Comments
 (0)