fix(integrations, project): loose check and correctly load configuration
MODIFY
internal/consume/Consumer.ts
internal/consume/Consumer.ts
@@ -20,6 +20,7 @@ import {
UnknownFunction,
UnknownObject,
VoidCallback,
+ isObject,
isPlainObject,
} from "@internal/typescript-helpers";
import {
@@ -829,7 +830,7 @@ export default class Consumer {
}
const {value} = this;
- if (!isPlainObject(value)) {
+ if (!isObject(value)) {
this.unexpected(descriptions.CONSUME.EXPECTED_OBJECT);
return {};
}
@@ -1001,7 +1002,7 @@ export default class Consumer {
public async asPromise(def?: PromiseLike<unknown>): Promise<Consumer> {
let value: unknown;
- if (this.isObject()) {
+ if (isObject(this.value)) {
const obj = this.asOriginalUnknownObject();
if (typeof obj.then === "function") {
value = await obj;

MODIFY
internal/project/constants.ts
internal/project/constants.ts
@@ -7,10 +7,7 @@ import {CONFIG_EXTENSIONS} from "@internal/codec-config";
export const VCS_IGNORE_FILENAMES = [".gitignore", ".hgignore"];
-export const ESLINT_CONFIG_FILENAMES: string[] = [
- ".eslintrc.json",
- ".eslintignore",
-];
+export const ESLINT_CONFIG_FILENAMES: string[] = [".eslintrc", ".eslintrc.json"];
// NOTE: only supporting JSON for now
export const PRETTIER_CONFIG_FILESNAMES: string[] = [

MODIFY
internal/project/load.ts
internal/project/load.ts
@@ -126,10 +126,12 @@ export async function loadCompleteProjectConfig(
if (await possiblePath.exists()) {
const file = await reader.readFileText(possiblePath);
const prettierConfig = loadPrettier(file, possiblePath.getExtensions());
+ consumer.handleThrownDiagnostics(() => {
config.integrations.prettier = {
...config.integrations.prettier,
...prettierConfig,
};
+ });
}
}
@@ -139,11 +141,13 @@ export async function loadCompleteProjectConfig(
meta.configDependencies.add(possiblePath);
if (await possiblePath.exists()) {
const file = await reader.readFileText(possiblePath);
+ consumer.handleThrownDiagnostics(() => {
const eslintConfig = loadEslint(file);
config.integrations.eslint = {
...config.integrations.eslint,
...eslintConfig,
};
+ });
}
}
@@ -515,8 +519,24 @@ export async function normalizeProjectConfig(
if (eslint.has("enabled")) {
config.integrations.eslint.enabled = eslint.get("enabled").asBoolean();
}
+ if (eslint.has("globInputPaths")) {
+ config.integrations.eslint.globInputPaths = eslint.get("globInputPaths").asBoolean();
+ }
+ if (eslint.has("extensions")) {
+ config.integrations.eslint.extensions = arrayOfStrings(
+ eslint.get("extensions"),
+ );
+ }
+ if (eslint.has("fix")) {
+ config.integrations.eslint.fix = eslint.get("fix").asBoolean();
+ }
+ if (eslint.has("rulePaths")) {
+ config.integrations.eslint.rulePaths = arrayOfStrings(
+ eslint.get("rulePaths"),
+ );
}
eslint.enforceUsedProperties("eslint config property");
+ }
const prettier = integrations.get("prettier");
if (categoryExists(prettier)) {

fix(integrations, project): loose check and correctly load configuration (#1581)