Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ max_line_length = 120
# -------------------------
# JavaScript / React
# -------------------------
[*.{js,jsx}]
[*.{js,ts,jsx,tsx}]
indent_style = space
indent_size = 2
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
max_line_length = 200

# -------------------------
# JSON
Expand Down Expand Up @@ -90,12 +90,15 @@ indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 200

# -------------------------
# Markdown
# -------------------------
[*.md]
indent_style = space
# Note: Prettier uses 3 spaces for nested list items, but enforcing 2 spaces
# at the file level while allowing editorconfig-checker to be lenient
indent_size = 2
trim_trailing_whitespace = false
insert_final_newline = true
Expand Down Expand Up @@ -142,9 +145,10 @@ max_line_length = off
# -------------------------
# LICENSE
# -------------------------
[LICENSE]
[LICENSE*]
max_line_length = off
trim_trailing_whitespace = false
insert_final_newline = true

# -------------------------
# Bash / Shell scripts
Expand All @@ -157,6 +161,7 @@ end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

# img2num is in bash
[img2num]
indent_style = space
Expand Down
40 changes: 40 additions & 0 deletions .editorconfig-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"Exclude": [
"node_modules",
"dist",
"build",
".git",
"package-lock.json",
"src/data/contributor-credits.json",
"docs/node_modules",
"docs/build",
"docs/.docusaurus",
"docs/package-lock.json",
"src/wasm/build",
"src/wasm/modules/image/build",
"\\.ase$",
"\\.min\\.js$",
"\\.min\\.css$",
"\\.lock$",
"CC-BY-SA-4\\.0\\.txt$",
"LICENSE.*",
"\\.md$",
"\\.mdx$",
"\\.py$",
"\\.bat$",
"\\.ps1$",
"^img2num$",
"\\.cpp$",
"\\.h$"
],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"IndentSize": false,
"MaxLineLength": false
}
}
36 changes: 25 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,62 @@ on:
branches: [main]

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Run format check
run: npm run format:check

- name: Run editorconfig-checker
run: npm run lint:style
validate-scripts:
runs-on: ubuntu-latest
steps:
# Checkout full history to ensure git diff works
- uses: actions/checkout@v6
with:
fetch-depth: 0

# Node.js setup
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22

# Install dependencies
- name: Install dependencies
run: npm ci

# Detect if scripts changed
- name: Determine if scripts changed
id: check_changes
shell: bash
run: |
echo "Checking for changed scripts..."

if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi

HEAD_SHA="${{ github.sha }}"

# Ensure a valid common ancestor (handles force-pushes)
BASE_SHA=$(git merge-base "$BASE_SHA" "$HEAD_SHA")

files=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
echo "Changed files: $files"

match=false
for file in $files; do
if [[ "$file" == "package.json" || "$file" == "docs/package.json" ]]; then
Expand All @@ -58,9 +75,7 @@ jobs:
break
fi
done

echo "scripts_changed=$match" >> "$GITHUB_OUTPUT"

# Run script validation if scripts changed
- name: Run script validation
id: validate
Expand All @@ -70,7 +85,6 @@ jobs:
set -o pipefail
npm run validate-scripts 2>&1 | tee validation.log
echo "validation_exit_code=${PIPESTATUS[0]}" >> $GITHUB_OUTPUT

# Comment on PR if validation fails
- name: Comment on PR if validation fails
if: steps.validate.outputs.validation_exit_code != '0' && github.event_name == 'pull_request'
Expand Down
Loading