Skip to content

Commit 5f86a72

Browse files
committed
refactor: avoid linting of node_modules
1 parent f44e851 commit 5f86a72

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nivalis/linter",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"module": "src/index.ts",
55
"type": "module",
66
"publishConfig": {

Diff for: src/biome.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ export const getBiomeConfig = (): Configuration => {
242242
config = JSON.parse(biomeConfig);
243243
}
244244

245-
console.log(config);
246-
247245
return config;
248246
} catch (error) {
249247
console.warn(error);
@@ -257,24 +255,29 @@ export const lintWithBiome = async (
257255
debug: boolean,
258256
unsafe: boolean,
259257
) => {
260-
const [biome, files, config] = await Promise.all([
258+
const [biome, config] = await Promise.all([
261259
Biome.create({
262260
distribution: Distribution.NODE,
263261
}),
264-
getFilesToLint(patterns),
265262
getBiomeConfig(),
266263
]);
264+
267265
biome.applyConfiguration(config);
268266

269267
if (debug) {
270268
performance.mark("biome-start");
271269
}
272270

273-
const biomeResults = await Promise.all(
274-
files.map(
275-
async (file) => await biomeLintFile(biome, config, file, fix, unsafe),
276-
),
277-
);
271+
const stream = getFilesToLint(patterns);
272+
273+
const biomeResults: ESLint.LintResult[] = [];
274+
275+
for await (const file of stream) {
276+
console.log(file);
277+
const result = await biomeLintFile(biome, config, file as string, fix, unsafe);
278+
biomeResults.push(result);
279+
}
280+
278281

279282
if (debug) {
280283
performance.mark("biome-end");

Diff for: src/files.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "node:path";
22
import fs from "node:fs";
33
import fg from "fast-glob";
44

5-
export const getFilesToLint = async (patterns: string[]) => {
5+
export const getFilesToLint = (patterns: string[]) => {
66
const globPatterns = patterns.flatMap((pattern) => {
77
if (!fs.existsSync(pattern)) {
88
return pattern;
@@ -21,6 +21,7 @@ export const getFilesToLint = async (patterns: string[]) => {
2121
return [];
2222
});
2323

24-
const files = await fg(globPatterns, { dot: true, absolute: true });
25-
return files;
24+
return fg.stream(globPatterns, { dot: true, absolute: true, ignore:
25+
["node_modules/**", "**/node_modules/**"]
26+
});
2627
};

0 commit comments

Comments
 (0)