File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -29332,6 +29332,10 @@ const linter = unified()
2933229332
2933329333paths.forEach(async (path) => {
2933429334 const file = await read(path);
29335+ // We need to calculate `fileContents` before running `linter.process(files)`
29336+ // because `linter.process(files)` mutates `file` and returns it as `result`.
29337+ // So we won't be able to use `file` after that to see if its contents have
29338+ // changed as they will have been altered to the changed version.
2933529339 const fileContents = file.toString();
2933629340 const result = await linter.process(file);
2933729341 if (format) {
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ const linter = unified()
2828
2929paths . forEach ( async ( path ) => {
3030 const file = await read ( path ) ;
31+ // We need to calculate `fileContents` before running `linter.process(files)`
32+ // because `linter.process(files)` mutates `file` and returns it as `result`.
33+ // So we won't be able to use `file` after that to see if its contents have
34+ // changed as they will have been altered to the changed version.
3135 const fileContents = file . toString ( ) ;
3236 const result = await linter . process ( file ) ;
3337 if ( format ) {
You can’t perform that action at this time.
0 commit comments