Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat(project): support ignore files for eslint and prettier (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Jun 18, 2021
1 parent df2fc45 commit 0c870f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/project/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const PRETTIER_CONFIG_FILESNAMES: string[] = [
".prettierr.json5",
];

export const INTEGRATIONS_IGNORE_FILES: string[] = [
".prettierignore",
".eslintignore",
];

export const PROJECT_CONFIG_PACKAGE_JSON_FIELD = "rome";
export const PROJECT_CONFIG_DIRECTORY = ".config";
export const PROJECT_CONFIG_FILENAMES: string[] = [];
Expand Down
20 changes: 20 additions & 0 deletions internal/project/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {CachedFileReader} from "@internal/fs";
import {parseSemverRange} from "@internal/codec-semver";
import {descriptions} from "@internal/diagnostics";
import {
INTEGRATIONS_IGNORE_FILES,
PRETTIER_CONFIG_FILESNAMES,
PROJECT_CONFIG_PACKAGE_JSON_FIELD,
VCS_IGNORE_FILENAMES,
Expand Down Expand Up @@ -119,6 +120,7 @@ export async function loadCompleteProjectConfig(
// Load extensions configuration of prettier
for (const prettierFile of PRETTIER_CONFIG_FILESNAMES) {
const possiblePath = projectDirectory.append(prettierFile);
meta.configDependencies.add(possiblePath);
if (await possiblePath.exists()) {
const file = await reader.readFileText(possiblePath);
const prettierConfig = loadPrettier(file, possiblePath.getExtensions());
Expand All @@ -129,6 +131,24 @@ export async function loadCompleteProjectConfig(
}
}

// read ignore files
for (const fileToIgnore of INTEGRATIONS_IGNORE_FILES) {
const possiblePath = projectDirectory.append(fileToIgnore);
meta.configDependencies.add(possiblePath);
if (await possiblePath.exists()) {
const file = await reader.readFileText(possiblePath);

consumer.handleThrownDiagnostics(() => {
const patterns = parsePathPatternsFile({
input: file,
path: possiblePath,
});

config.lint.ignore = [...config.lint.ignore, ...patterns];
});
}
}

// Calculate config hash keys
await Promise.all(
Array.from(
Expand Down

0 comments on commit 0c870f6

Please sign in to comment.