Skip to content

Commit

Permalink
feat(builder): add resolvePluginsRelativeTo option (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry authored Jul 11, 2021
1 parent ff9557d commit 3bea308
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/builder/src/lint.impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function createValidRunBuilderOptions(
outputFile: null,
noEslintrc: false,
rulesdir: [],
resolvePluginsRelativeTo: null,
...additionalOptions,
};
}
Expand Down Expand Up @@ -149,6 +150,7 @@ describe('Linter Builder', () => {
ignorePath: null,
noEslintrc: false,
rulesdir: [],
resolvePluginsRelativeTo: null,
}),
mockContext,
);
Expand All @@ -172,6 +174,7 @@ describe('Linter Builder', () => {
ignorePath: null,
noEslintrc: false,
rulesdir: [],
resolvePluginsRelativeTo: null,
},
);
});
Expand Down
1 change: 1 addition & 0 deletions packages/builder/src/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Schema extends JsonObject {
outputFile: string | null;
noEslintrc: boolean;
rulesdir: string[];
resolvePluginsRelativeTo: string | null;
}

type Formatter =
Expand Down
4 changes: 4 additions & 0 deletions packages/builder/src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
"items": {
"type": "string"
}
},
"resolvePluginsRelativeTo": {
"type": "string",
"description": "The equivalent of the --resolve-plugins-relative-to flag on the ESLint CLI"
}
},
"additionalProperties": false,
Expand Down
25 changes: 25 additions & 0 deletions packages/builder/src/utils/eslint-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,29 @@ describe('eslint-utils', () => {
});
});
});

describe('resolvePluginsRelativeTo', () => {
it('should create the ESLint instance with "resolvePluginsRelativeTo" set to the given value for resolvePluginsRelativeTo', async () => {
await lint('/root', undefined, {
fix: true,
cache: true,
cacheLocation: '/root/cache',
cacheStrategy: 'content',
resolvePluginsRelativeTo: './some-path',
// eslint-disable-next-line @typescript-eslint/no-empty-function
}).catch(() => {});

expect(ESLint).toHaveBeenCalledWith({
fix: true,
cache: true,
cacheLocation: '/root/cache',
cacheStrategy: 'content',
ignorePath: undefined,
useEslintrc: true,
errorOnUnmatchedPattern: false,
rulePaths: [],
resolvePluginsRelativeTo: './some-path',
});
});
});
});
1 change: 1 addition & 0 deletions packages/builder/src/utils/eslint-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function lint(
cache: !!options.cache,
cacheLocation: options.cacheLocation || undefined,
cacheStrategy: options.cacheStrategy || undefined,
resolvePluginsRelativeTo: options.resolvePluginsRelativeTo || undefined,
rulePaths: options.rulesdir || [],
/**
* Default is `true` and if not overridden the eslint.lintFiles() method will throw an error
Expand Down

0 comments on commit 3bea308

Please # to comment.