Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrap rel_fname in quote #3204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

princejoogie
Copy link

resolves: #3182

Summary

Wraps rel_fname in double quotes (") for linter.py so that filepaths with ()[] characters e.g. src/(main)/product/[id]/page.tsx is recognized as one argument instead of shell trying to parse it as glob paths.

@miradnanali
Copy link
Contributor

miradnanali commented Feb 10, 2025

I posted a slightly more general solution to this exact problem in PR #3192 . The same solution would apply here, I believe.

@princejoogie
Copy link
Author

im fine with either to be merged @miradnanali. currently still using a forked version since the /lint command doest work

@miradnanali
Copy link
Contributor

miradnanali commented Feb 11, 2025

@princejoogie Could I ask, what do you use for linting?

Currently I set lint-cmd to "./lint-nextjs.sh #" to ignore the filename passed and use a script as follows, which verifies the entire codebase. Lines too slow to run every time are commented out, and the timestamp stops the script from running per file changed. Some kind of global lint mode, running once over the entire code base, might be helpful for this kind of linting.

lint-nextjs.sh

#!/bin/bash
set -e

TS_FILE=".lint-nextjs-timestamp"

should_run() {
    [[ ! -f "$TS_FILE" ]] && return 0
    find . \( -path "./.git" -o -path "./.next" -o -path "./node_modules" \) -prune -o \
           -type f \( -name "*.json" -o -name "*.ts" -o -name "*.tsx" -o -name "*.js" \) \
           -newer "$TS_FILE" -print | grep -q .
}

run_lint() {
    echo "lint-nextjs : Running lint checks..."
    touch "$TS_FILE"
    tsc --noEmit
    #npm run lint
    find . -name "*.json" -print0 | xargs -0 npx jsonlint -q
    node --check "next.config.mjs"
    set -o allexport && source .env.local && set +o allexport # one for each .env file
    #npx madge --extensions ts,tsx,js --circular --orphans src/
    #npm run build
    echo "lint-nextjs : Completed without error."
}

if should_run; then
    run_lint
else
    echo "lint-nextjs : Lint checks skipped."
fi

@princejoogie
Copy link
Author

@miradnanali i simply just run eslint --fix --quiet and aider passes the filepath.

lint-cmd:
  - "typescript:npx eslint --fix --quiet"
  - "typescriptreact:npx eslint --fix --quiet"
  - "javascript:npx eslint --fix --quiet"
  - "javascriptreact:npx eslint --fix --quiet"

then aider runs it like: eslint --fix --quiet src/app/(main)/page.tsx.

i'm having problems since i need the path to be wrapped in quotes for the shell to recognize it as 1 argument: eslint --fix --quiet "src/app/(main)/page.tsx"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linting error on file paths with ()[] characters
3 participants