Comments (6)
Related issue with a proposed solution that doesn't require file system operations: #1383
Thanks! I will provide a fix now that there's multiple issues.
from lint-staged.
I tested it locally and yes it has been fixed and no more errors. The debug log is as follows:
DEBUG=* testlint-staged
lint-staged:bin Running `[email protected]` on Node.js v16.20.2 (darwin) +0ms
lint-staged:bin Options parsed from command-line: {
allowEmpty: false,
concurrent: true,
configPath: undefined,
cwd: undefined,
debug: false,
diff: undefined,
diffFilter: undefined,
maxArgLength: undefined,
quiet: false,
relative: false,
shell: false,
stash: true,
hidePartiallyStaged: true,
verbose: false
} +1ms
lint-staged:validateOptions Validating options... +0ms
lint-staged:validateOptions Validated options! +0ms
lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
lint-staged:runAll Running all linter scripts... +0ms
lint-staged:runAll Using working directory `/Users/admin/code/lint-staged-sparse-issue` +0ms
lint-staged:resolveGitRepo Resolving git repo from `/Users/admin/code/lint-staged-sparse-issue` +0ms
lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +0ms
lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ] +0ms
lint-staged:resolveGitRepo Resolved git directory to be `/Users/admin/code/lint-staged-sparse-issue` +18ms
lint-staged:resolveGitRepo Resolved git config directory to be `/Users/admin/code/lint-staged-sparse-issue/.git` +0ms
lint-staged:execGit Running git command [ 'log', '-1' ] +19ms
lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +23ms
lint-staged:runAll Loaded list of staged files in git:
lint-staged:runAll [ '/Users/admin/code/lint-staged-sparse-issue/apps/app1/a.txt' ] +76ms
lint-staged:searchConfigs Searching for configuration files... +0ms
lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name', '-t' ] +34ms
lint-staged:execGit Running git command [
'ls-files',
'-z',
'--full-name',
'-t',
'--others',
'--exclude-standard'
] +3ms
lint-staged:searchConfigs Found possible config files: [
'/Users/admin/code/lint-staged-sparse-issue/apps/app1/package.json',
'/Users/admin/code/lint-staged-sparse-issue/apps/app1/.lintstagedrc.cjs',
'/Users/admin/code/lint-staged-sparse-issue/package.json'
] +37ms
lint-staged:loadConfig Loading configuration from `/Users/admin/code/lint-staged-sparse-issue/apps/app1/package.json`... +0ms
lint-staged:loadConfig Loading configuration from `/Users/admin/code/lint-staged-sparse-issue/apps/app1/.lintstagedrc.cjs`... +0ms
lint-staged:loadConfig Loading configuration from `/Users/admin/code/lint-staged-sparse-issue/package.json`... +0ms
lint-staged:loadConfig Successfully loaded config from `/Users/admin/code/lint-staged-sparse-issue/apps/app1/.lintstagedrc.cjs`:
lint-staged:loadConfig { '*': "echo 'good'" } +1ms
lint-staged:validateConfig Validating config from `/Users/admin/code/lint-staged-sparse-issue/apps/app1/.lintstagedrc.cjs`... +0ms
lint-staged:validateConfig Validated config from `/Users/admin/code/lint-staged-sparse-issue/apps/app1/.lintstagedrc.cjs`: +0ms
lint-staged:validateConfig {
lint-staged:validateConfig '*': "echo 'good'"
lint-staged:validateConfig } +0ms
lint-staged:loadConfig Successfully loaded config from `/Users/admin/code/lint-staged-sparse-issue/package.json`:
lint-staged:loadConfig null +1ms
lint-staged:loadConfig Successfully loaded config from `/Users/admin/code/lint-staged-sparse-issue/apps/app1/package.json`:
lint-staged:loadConfig null +0ms
lint-staged:searchConfigs Found 1 config files +3ms
lint-staged:groupFilesByConfig Grouping 1 files by 1 configurations +0ms
lint-staged:chunkFiles Resolved an argument string length of 58 characters from 1 files +0ms
lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 131072 +0ms
lint-staged:generateTasks Generating linter tasks +0ms
lint-staged:generateTasks Generated task:
lint-staged:generateTasks {
lint-staged:generateTasks pattern: '*',
lint-staged:generateTasks commands: "echo 'good'",
lint-staged:generateTasks fileList: [ '/Users/admin/code/lint-staged-sparse-issue/apps/app1/a.txt' ]
lint-staged:generateTasks } +0ms
lint-staged:makeCmdTasks Creating listr tasks for commands "echo 'good'" +0ms
lint-staged:resolveTaskFn cmd: echo +0ms
lint-staged:resolveTaskFn args: [ 'good' ] +0ms
lint-staged:resolveTaskFn execaOptions: {
cwd: '/Users/admin/code/lint-staged-sparse-issue',
preferLocal: true,
reject: false,
shell: false,
stdin: 'ignore'
} +0ms
lint-staged:chunkFiles Resolved an argument string length of 58 characters from 1 files +1ms
lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 131072 +0ms
✔ Preparing lint-staged...
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
lint-staged:GitWorkflow Backing up original state... +0ms
lint-staged:GitWorkflow Getting partially staged files... +1ms
lint-staged:execGit Running git command [ 'status', '-z' ] +92ms
lint-staged:GitWorkflow Found partially staged files: [] +29ms
lint-staged:GitWorkflow Backing up merge state... +0ms
lint-staged:file Reading file `/Users/admin/code/lint-staged-sparse-issue/.git/MERGE_HEAD` +0ms
lint-staged:file Reading file `/Users/admin/code/lint-staged-sparse-issue/.git/MERGE_MODE` +0ms
lint-staged:file Reading file `/Users/admin/code/lint-staged-sparse-issue/.git/MERGE_MSG` +0ms
lint-staged:file File `/Users/admin/code/lint-staged-sparse-issue/.git/MERGE_HEAD` doesn't exist, ignoring... +0ms
lint-staged:file File `/Users/admin/code/lint-staged-sparse-issue/.git/MERGE_MODE` doesn't exist, ignoring... +0ms
lint-staged:file File `/Users/admin/code/lint-staged-sparse-issue/.git/MERGE_MSG` doesn't exist, ignoring... +0ms
lint-staged:GitWorkflow Done backing up merge state! +0ms
lint-staged:GitWorkflow Getting deleted files... +0ms
lint-staged:execGit Running git command [ 'ls-files', '--deleted' ] +29ms
lint-staged:GitWorkflow Found deleted files: [] +26ms
lint-staged:execGit Running git command [ 'stash', 'create' ] +26ms
lint-staged:execGit Running git command [
'stash',
'store',
'--quiet',
'--message',
'lint-staged automatic backup',
'01dfce55f75c37769f25240d49526f4f2f8ab369'
] +78ms
lint-staged:GitWorkflow Done backing up original state! +94ms
lint-staged:GitWorkflow Adding task modifications to index... +37ms
lint-staged:execGit Running git command [
'add',
'--',
'/Users/admin/code/lint-staged-sparse-issue/apps/app1/a.txt'
] +53ms
lint-staged:GitWorkflow Done adding task modifications to index! +31ms
lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +31ms
lint-staged:GitWorkflow Dropping backup stash... +30ms
lint-staged:execGit Running git command [ 'stash', 'list' ] +30ms
lint-staged:execGit Running git command [ 'stash', 'drop', '--quiet', '0' ] +25ms
lint-staged:GitWorkflow Done dropping backup stash! +51ms
lint-staged Tasks were executed successfully! +470ms
from lint-staged.
A possible solution to this issue could be reading the file content of missing package.json from git as well, since the existence of those package.json are read from git.
It could happen at this line of code:
Line 83 in 999dcce
I would like to put my psedocode here to show the idea:
BEFORE:
const loadConfigByExt = async (filepath) => {
// ...
const content = await readFile(filepath);
// ...
}
AFTER:
const loadConfigByExt = async (filepath) => {
// ...
const content = fs.exists(filepath) ? await readFile(filepath) : await readFileFromGit(filepath) ;
// ...
}
function readFileFromGit(filepath) {
const relativeFilepath = getRelativeFilepathSomehow(filepath):
const content = exec(`git show HEAD:${relativeFilepath}`);
return content;
}
from lint-staged.
@chengcyber would you mind testing the linked PR in your setup?
from lint-staged.
@iiroj Sure. I am glad to test it. Is there a specific prerelease version I can run locally?
from lint-staged.
Sorry no, easiest is to copy/paste the changes into your node_modules/lint-staged/lib/
as there is no build step or anything. 👍
from lint-staged.
Related Issues (20)
- Importing a reusable json file to ESM JS config fails HOT 1
- Path for baseConfig HOT 2
- lint-staged is unable to resolve path to module in Monorepo with map imports HOT 9
- Many errors in standard output when using git sparse-checkout HOT 4
- `--all` flag HOT 3
- lint-staged repeat many time ,when commit in windows powershell,cmd HOT 2
- [feat] override the current pattern HOT 1
- How to `git reset $file` ? HOT 3
- How to output the print content of the script in lint-staged in real time?
- `npx lint-staged --cwd $PWD` for all OS HOT 6
- Hooks to know if the lint staged commands have completed HOT 4
- Prettier breaks when run through lint-staged on files with dollar sign ($) in the name HOT 6
- Consider allowing running of programatic tasks via Node API HOT 5
- Is it possible to run 2 different configurations for pre-commit and pre-push? HOT 1
- No staged files found. with command "npx lint-staged"
- Hard to understand stashing behavior HOT 2
- Case sensitivity in finding .git root folder HOT 3
- firebase emulator is not running by lint-staged HOT 8
- SyntaxError: Named export 'getStreamAsBuffer' not found HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lint-staged.