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

Script fails when using grouped layouts in Next.js #1412

Open
pulgueta opened this issue May 8, 2024 · 5 comments
Open

Script fails when using grouped layouts in Next.js #1412

pulgueta opened this issue May 8, 2024 · 5 comments

Comments

@pulgueta
Copy link

pulgueta commented May 8, 2024

Description

When using Next.js (14.2.3) I create grouped layouts but when I try to commit my pages under a grouped layout it just won't work.

image
image
image

Tried multiple ways to check what was the error and it runs flawlessly if I remove the lint-staged run in the pre-commit executable from Husky.

Doesn't work
image

Works
image

Steps to reproduce

  1. Create or edit a file.
  2. Run git commands to commit the file or just do it visually in VS Code.
  3. Fail.

Debug Logs

expand to view
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
$ eslint --fix && prettier --check . --write
Checking formatting...
All matched files use Prettier code style!
2024-05-08T20:56:53.282Z lint-staged:bin Running `[email protected]` on Node.js v20.12.2 (win32)
2024-05-08T20:56:53.283Z lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  cwd: undefined,
  debug: true,
  diff: undefined,
  diffFilter: undefined,
  maxArgLength: undefined,
  quiet: false,
  relative: false,
  shell: false,
  stash: false,
  hidePartiallyStaged: false,
  verbose: false
}
2024-05-08T20:56:53.285Z lint-staged:validateOptions Validating options...
2024-05-08T20:56:53.285Z lint-staged:validateOptions Validated options!
2024-05-08T20:56:53.285Z lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`)
2024-05-08T20:56:53.286Z lint-staged:runAll Running all linter scripts...
2024-05-08T20:56:53.286Z lint-staged:runAll Using working directory `C:\Users\retar\Documents\oss-interviewer`
2024-05-08T20:56:53.286Z lint-staged:resolveGitRepo Resolving git repo from `C:\Users\retar\Documents\oss-interviewer`
2024-05-08T20:56:53.286Z lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`)
2024-05-08T20:56:53.286Z lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`)
2024-05-08T20:56:53.286Z lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ]
2024-05-08T20:56:53.322Z lint-staged:resolveGitRepo Resolved git directory to be `C:/Users/retar/Documents/oss-interviewer`
2024-05-08T20:56:53.322Z lint-staged:resolveGitRepo Resolved git config directory to be `C:/Users/retar/Documents/oss-interviewer/.git`
2024-05-08T20:56:53.322Z lint-staged:execGit Running git command [ 'log', '-1' ]
⚠ Skipping backup because `--no-stash` was used.

⚠ Skipping hiding unstaged changes from partially staged files because `--no-stash` was used.

2024-05-08T20:56:53.354Z lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ]
2024-05-08T20:56:53.385Z lint-staged:runAll Loaded list of staged files in git:
[
  'C:/Users/retar/Documents/oss-interviewer/app/(dashboard)/dashboard/settings/page.tsx'
]
2024-05-08T20:56:53.385Z lint-staged:searchConfigs Searching for configuration files...
2024-05-08T20:56:53.385Z lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name', '-t' ]
2024-05-08T20:56:53.390Z lint-staged:execGit Running git command [
  'ls-files',
  '-z',
  '--full-name',
  '-t',
  '--others',
  '--exclude-standard'
]
2024-05-08T20:56:53.425Z lint-staged:searchConfigs Found possible config files: [
  'C:/Users/retar/Documents/oss-interviewer/.lintstagedrc',
  'C:/Users/retar/Documents/oss-interviewer/package.json'
]
2024-05-08T20:56:53.426Z lint-staged:loadConfig Loading configuration from `C:/Users/retar/Documents/oss-interviewer/.lintstagedrc`...
2024-05-08T20:56:53.426Z lint-staged:loadConfig Loading configuration from `C:/Users/retar/Documents/oss-interviewer/package.json`...
2024-05-08T20:56:53.432Z lint-staged:loadConfig Successfully loaded config from `C:\Users\retar\Documents\oss-interviewer\.lintstagedrc`:
{ '**/*.{ts,tsx}': [ 'bun run prettier' ] }
2024-05-08T20:56:53.432Z lint-staged:searchConfigs Config file "C:/Users/retar/Documents/oss-interviewer/.lintstagedrc" resolved to "C:\Users\retar\Documents\oss-interviewer\.lintstagedrc"
2024-05-08T20:56:53.433Z lint-staged:validateConfig Validating config from `C:\Users\retar\Documents\oss-interviewer\.lintstagedrc`...
2024-05-08T20:56:53.433Z lint-staged:validateConfig Validated config from `C:\Users\retar\Documents\oss-interviewer\.lintstagedrc`:
2024-05-08T20:56:53.433Z lint-staged:validateConfig {
  '**/*.{ts,tsx}': [
    'bun run prettier'
  ]
}
2024-05-08T20:56:53.433Z lint-staged:loadConfig Successfully loaded config from `C:\Users\retar\Documents\oss-interviewer\package.json`:
null
2024-05-08T20:56:53.433Z lint-staged:searchConfigs Found 1 config files
2024-05-08T20:56:53.433Z lint-staged:groupFilesByConfig Grouping 1 files by 1 configurations
2024-05-08T20:56:53.434Z lint-staged:chunkFiles Resolved an argument string length of 84 characters from 1 files
2024-05-08T20:56:53.434Z lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 4095.5
2024-05-08T20:56:53.434Z lint-staged:generateTasks Generating linter tasks
2024-05-08T20:56:53.437Z lint-staged:generateTasks Generated task: 
{
  pattern: '**/*.{ts,tsx}',
  commands: [ 'bun run prettier' ],
  fileList: [
    'C:/Users/retar/Documents/oss-interviewer/app/(dashboard)/dashboard/settings/page.tsx'
  ]
}
2024-05-08T20:56:53.438Z lint-staged:makeCmdTasks Creating listr tasks for commands [ 'bun run prettier' ]
2024-05-08T20:56:53.438Z lint-staged:resolveTaskFn cmd: bun
2024-05-08T20:56:53.438Z lint-staged:resolveTaskFn args: [ 'run', 'prettier' ]
2024-05-08T20:56:53.438Z lint-staged:resolveTaskFn execaOptions: {
  cwd: 'C:\\Users\\retar\\Documents\\oss-interviewer',
  preferLocal: true,
  reject: false,
  shell: false,
  stdin: 'ignore'
}
2024-05-08T20:56:53.439Z lint-staged:chunkFiles Resolved an argument string length of 84 characters from 1 files
2024-05-08T20:56:53.439Z lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 4095.5
�[33m[STARTED]�[39m Preparing lint-staged...
2024-05-08T20:56:53.442Z lint-staged:GitWorkflow Backing up original state...
2024-05-08T20:56:53.442Z lint-staged:GitWorkflow Getting partially staged files...
2024-05-08T20:56:53.442Z lint-staged:execGit Running git command [ 'status', '-z' ]
2024-05-08T20:56:53.479Z lint-staged:GitWorkflow Found partially staged files: []
�[32m[COMPLETED]�[39m Preparing lint-staged...
�[33m[STARTED]�[39m Running tasks for staged files...
�[33m[STARTED]�[39m .lintstagedrc — 1 file
�[33m[STARTED]�[39m **/*.{ts,tsx} — 1 file
�[33m[STARTED]�[39m bun run prettier
�[31m[FAILED]�[39m bun run prettier [FAILED]
�[31m[FAILED]�[39m bun run prettier [FAILED]
�[32m[COMPLETED]�[39m Running tasks for staged files...
�[33m[STARTED]�[39m Applying modifications from tasks...
2024-05-08T20:56:53.535Z lint-staged:GitWorkflow Adding task modifications to index...
2024-05-08T20:56:53.535Z lint-staged:execGit Running git command [
  'add',
  '--',
  'C:/Users/retar/Documents/oss-interviewer/app/(dashboard)/dashboard/settings/page.tsx'
]
2024-05-08T20:56:53.568Z lint-staged:GitWorkflow Done adding task modifications to index!
2024-05-08T20:56:53.568Z lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ]
�[32m[COMPLETED]�[39m Applying modifications from tasks...

✖ bun run prettier:
$ eslint --fix && prettier --check . --write C:/Users/retar/Documents/oss-interviewer/app/(dashboard)/dashboard/settings/page.tsx
error: Failed to run script prettier due to error Unexpected token: `(`
husky - pre-commit script failed (code 1)

Environment

  • OS: Microsoft Windows NT 10.0.22631.0 x64
  • Node.js: 20.12.2
  • Bun: 1.1.7
  • lint-staged: 15.2.2
@iiroj
Copy link
Member

iiroj commented May 9, 2024

Hello, what is your lint-staged config?

@iiroj
Copy link
Member

iiroj commented May 9, 2024

To rule out some configuration/environment issues, does it work with this kind of setup:

// lint-staged config
export default {
  "**/*.{js,jsx,ts,tsx}: ["eslint --fix", "prettier --write"]
}
# Husky command to invoke lint-staged
npx lint-staged

@okonet
Copy link
Collaborator

okonet commented May 9, 2024

There is an official guide from next.js here https://nextjs.org/docs/app/building-your-application/configuring/eslint#lint-staged. Have you tried it? It worked for me the last time I tried.

@pulgueta
Copy link
Author

pulgueta commented May 9, 2024

Hello, what is your lint-staged config?

Hey! This is my lint-staged config file:

.lintstagedrc

{
    "**/*.{ts,tsx}": ["bun run prettier"]
}

@mrevanzak
Copy link

it also happens to me

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

No branches or pull requests

4 participants