Skip to content

Commit 3bea308

Browse files
authored
feat(builder): add resolvePluginsRelativeTo option (#590)
1 parent ff9557d commit 3bea308

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

packages/builder/src/lint.impl.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function createValidRunBuilderOptions(
7171
outputFile: null,
7272
noEslintrc: false,
7373
rulesdir: [],
74+
resolvePluginsRelativeTo: null,
7475
...additionalOptions,
7576
};
7677
}
@@ -149,6 +150,7 @@ describe('Linter Builder', () => {
149150
ignorePath: null,
150151
noEslintrc: false,
151152
rulesdir: [],
153+
resolvePluginsRelativeTo: null,
152154
}),
153155
mockContext,
154156
);
@@ -172,6 +174,7 @@ describe('Linter Builder', () => {
172174
ignorePath: null,
173175
noEslintrc: false,
174176
rulesdir: [],
177+
resolvePluginsRelativeTo: null,
175178
},
176179
);
177180
});

packages/builder/src/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Schema extends JsonObject {
1616
outputFile: string | null;
1717
noEslintrc: boolean;
1818
rulesdir: string[];
19+
resolvePluginsRelativeTo: string | null;
1920
}
2021

2122
type Formatter =

packages/builder/src/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
"items": {
102102
"type": "string"
103103
}
104+
},
105+
"resolvePluginsRelativeTo": {
106+
"type": "string",
107+
"description": "The equivalent of the --resolve-plugins-relative-to flag on the ESLint CLI"
104108
}
105109
},
106110
"additionalProperties": false,

packages/builder/src/utils/eslint-utils.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,29 @@ describe('eslint-utils', () => {
110110
});
111111
});
112112
});
113+
114+
describe('resolvePluginsRelativeTo', () => {
115+
it('should create the ESLint instance with "resolvePluginsRelativeTo" set to the given value for resolvePluginsRelativeTo', async () => {
116+
await lint('/root', undefined, {
117+
fix: true,
118+
cache: true,
119+
cacheLocation: '/root/cache',
120+
cacheStrategy: 'content',
121+
resolvePluginsRelativeTo: './some-path',
122+
// eslint-disable-next-line @typescript-eslint/no-empty-function
123+
}).catch(() => {});
124+
125+
expect(ESLint).toHaveBeenCalledWith({
126+
fix: true,
127+
cache: true,
128+
cacheLocation: '/root/cache',
129+
cacheStrategy: 'content',
130+
ignorePath: undefined,
131+
useEslintrc: true,
132+
errorOnUnmatchedPattern: false,
133+
rulePaths: [],
134+
resolvePluginsRelativeTo: './some-path',
135+
});
136+
});
137+
});
113138
});

packages/builder/src/utils/eslint-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export async function lint(
3131
cache: !!options.cache,
3232
cacheLocation: options.cacheLocation || undefined,
3333
cacheStrategy: options.cacheStrategy || undefined,
34+
resolvePluginsRelativeTo: options.resolvePluginsRelativeTo || undefined,
3435
rulePaths: options.rulesdir || [],
3536
/**
3637
* Default is `true` and if not overridden the eslint.lintFiles() method will throw an error

0 commit comments

Comments
 (0)