Skip to content

Commit 5866a17

Browse files
authored
Remove unneeded async create config (#790)
1 parent 35b8320 commit 5866a17

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

lib/xo-to-eslint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type CreateConfigOptions = {
1717
/**
1818
Takes a XO flat config and returns an ESlint flat config.
1919
*/
20-
export async function xoToEslintConfig(flatXoConfig: XoConfigItem[] | undefined, {prettierOptions = {}}: CreateConfigOptions = {}): Promise<Linter.Config[]> {
20+
export function xoToEslintConfig(flatXoConfig: XoConfigItem[] | undefined, {prettierOptions = {}}: CreateConfigOptions = {}): Linter.Config[] {
2121
const baseConfig = [...config];
2222

2323
/**

lib/xo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ export class Xo {
228228
229229
@private
230230
*/
231-
async setEslintConfig() {
231+
setEslintConfig() {
232232
if (!this.xoConfig) {
233233
throw new Error('"Xo.setEslintConfig" failed');
234234
}
235235

236-
this.eslintConfig ??= await xoToEslintConfig([...this.xoConfig], {prettierOptions: this.prettierConfig});
236+
this.eslintConfig ??= xoToEslintConfig([...this.xoConfig], {prettierOptions: this.prettierConfig});
237237
}
238238

239239
/**
@@ -310,7 +310,7 @@ export class Xo {
310310

311311
await this.handleUnincludedTsFiles(files);
312312

313-
await this.setEslintConfig();
313+
this.setEslintConfig();
314314

315315
if (!this.xoConfig) {
316316
throw new Error('"Xo.initEslint" failed');

test/xo-to-eslint.test.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ test.afterEach.always(async t => {
1515
await fs.rm(t.context.cwd, {recursive: true, force: true});
1616
});
1717

18-
test('base config rules', async t => {
19-
const flatConfig = await xoToEslintConfig(undefined);
18+
test('base config rules', t => {
19+
const flatConfig = xoToEslintConfig(undefined);
2020

2121
t.deepEqual(getJsRule(flatConfig, '@stylistic/indent'), [
2222
'error',
@@ -28,8 +28,8 @@ test('base config rules', async t => {
2828
t.deepEqual(getJsRule(flatConfig, '@stylistic/quotes'), ['error', 'single']);
2929
});
3030

31-
test('empty config rules', async t => {
32-
const flatConfig = await xoToEslintConfig([]);
31+
test('empty config rules', t => {
32+
const flatConfig = xoToEslintConfig([]);
3333

3434
t.deepEqual(getJsRule(flatConfig, '@stylistic/indent'), [
3535
'error',
@@ -41,8 +41,8 @@ test('empty config rules', async t => {
4141
t.deepEqual(getJsRule(flatConfig, '@stylistic/quotes'), ['error', 'single']);
4242
});
4343

44-
test('config with space option', async t => {
45-
const flatConfig = await xoToEslintConfig([{space: true}]);
44+
test('config with space option', t => {
45+
const flatConfig = xoToEslintConfig([{space: true}]);
4646

4747
t.deepEqual(getJsRule(flatConfig, '@stylistic/indent'), [
4848
'error',
@@ -52,20 +52,20 @@ test('config with space option', async t => {
5252
]);
5353
});
5454

55-
test('config with semi false option', async t => {
56-
const flatConfig = await xoToEslintConfig([{semicolon: false}]);
55+
test('config with semi false option', t => {
56+
const flatConfig = xoToEslintConfig([{semicolon: false}]);
5757

5858
t.deepEqual(getJsRule(flatConfig, '@stylistic/semi'), ['error', 'never']);
5959
});
6060

61-
test('config with rules', async t => {
62-
const flatConfig = await xoToEslintConfig([{rules: {'no-console': 'error'}}]);
61+
test('config with rules', t => {
62+
const flatConfig = xoToEslintConfig([{rules: {'no-console': 'error'}}]);
6363

6464
t.is(getJsRule(flatConfig, 'no-console'), 'error');
6565
});
6666

67-
test('with prettier option', async t => {
68-
const flatConfig = await xoToEslintConfig([{prettier: true}]);
67+
test('with prettier option', t => {
68+
const flatConfig = xoToEslintConfig([{prettier: true}]);
6969

7070
const prettierConfigTs = flatConfig.find(config =>
7171
typeof config?.plugins?.['prettier'] === 'object'
@@ -106,8 +106,8 @@ test('with prettier option', async t => {
106106
]);
107107
});
108108

109-
test('with prettier option compat', async t => {
110-
const flatConfig = await xoToEslintConfig([{prettier: 'compat'}]);
109+
test('with prettier option compat', t => {
110+
const flatConfig = xoToEslintConfig([{prettier: 'compat'}]);
111111

112112
const prettierConfigTs = flatConfig.find(config =>
113113
typeof config?.plugins?.['prettier'] === 'object'
@@ -126,8 +126,8 @@ test('with prettier option compat', async t => {
126126
t.is(getJsRule(flatConfig, '@stylistic/semi'), 'off');
127127
});
128128

129-
test('with prettier option and space', async t => {
130-
const flatConfig = await xoToEslintConfig([{prettier: true, space: true}]);
129+
test('with prettier option and space', t => {
130+
const flatConfig = xoToEslintConfig([{prettier: true, space: true}]);
131131

132132
const prettierConfigTs = flatConfig.find(config =>
133133
typeof config?.plugins?.['prettier'] === 'object'
@@ -168,8 +168,8 @@ test('with prettier option and space', async t => {
168168
]);
169169
});
170170

171-
test('with react option', async t => {
172-
const flatConfig = await xoToEslintConfig([{react: true}]);
171+
test('with react option', t => {
172+
const flatConfig = xoToEslintConfig([{react: true}]);
173173

174174
const reactPlugin = flatConfig.find(config =>
175175
typeof config?.plugins?.['react'] === 'object');
@@ -182,20 +182,20 @@ test('with react option', async t => {
182182
t.is(getJsRule(flatConfig, 'react/no-danger'), 'error');
183183
});
184184

185-
test('supports files config option as a string', async t => {
186-
const flatConfig = await xoToEslintConfig([{files: 'src/**/*.ts'}]);
185+
test('supports files config option as a string', t => {
186+
const flatConfig = xoToEslintConfig([{files: 'src/**/*.ts'}]);
187187

188188
t.deepEqual(flatConfig.at(-1)?.files, ['src/**/*.ts']);
189189
});
190190

191-
test('no files config option defaults to allFilesGlob', async t => {
192-
const flatConfig = await xoToEslintConfig([{files: undefined}]);
191+
test('no files config option defaults to allFilesGlob', t => {
192+
const flatConfig = xoToEslintConfig([{files: undefined}]);
193193

194194
t.deepEqual(flatConfig.at(-1)?.files, [allFilesGlob]);
195195
});
196196

197-
test('prettier rules are applied after react rules', async t => {
198-
const flatConfig = await xoToEslintConfig([{prettier: 'compat', react: true}]);
197+
test('prettier rules are applied after react rules', t => {
198+
const flatConfig = xoToEslintConfig([{prettier: 'compat', react: true}]);
199199

200200
t.is(getJsRule(flatConfig, 'react/jsx-tag-spacing'), 'off');
201201
});

0 commit comments

Comments
 (0)