|
1 | | -import { writeFile } from 'node:fs/promises'; |
| 1 | +import { mkdtemp, rm, writeFile } from 'node:fs/promises'; |
| 2 | +import { join } from 'node:path'; |
| 3 | +import { tmpdir } from 'node:os'; |
2 | 4 |
|
3 | 5 | import replaceBackslashes from '../testUtils/replaceBackslashes.mjs'; |
4 | 6 | import standalone from '../standalone.mjs'; |
@@ -137,7 +139,7 @@ it('rejects on unknown custom syntax option', async () => { |
137 | 139 | config: config(), |
138 | 140 | }), |
139 | 141 | ).rejects.toThrow( |
140 | | - 'Could not find "unknown-module". Do you need to install the package or use the "configBasedir" option?', |
| 142 | + 'Cannot resolve custom syntax module "unknown-module". Check that module "unknown-module" is available and spelled correctly.', |
141 | 143 | ); |
142 | 144 | }); |
143 | 145 |
|
@@ -178,6 +180,26 @@ describe('customSyntax set in the config', () => { |
178 | 180 | expect(results[0].warnings[0]).toMatchObject({ line: 2, column: 3, rule: 'block-no-empty' }); |
179 | 181 | }); |
180 | 182 |
|
| 183 | + it('standalone with bare-package custom syntax not reachable from configBasedir or cwd', async () => { |
| 184 | + const isolatedDir = await mkdtemp(join(tmpdir(), 'stylelint-isolated-')); |
| 185 | + |
| 186 | + try { |
| 187 | + const { results } = await standalone({ |
| 188 | + config: config({ customSyntax: 'postcss-scss' }), |
| 189 | + configBasedir: isolatedDir, |
| 190 | + cwd: isolatedDir, |
| 191 | + code: '$foo: bar; // foo;\nb {}', |
| 192 | + formatter: stringFormatter, |
| 193 | + }); |
| 194 | + |
| 195 | + expect(results).toHaveLength(1); |
| 196 | + expect(results[0].warnings).toHaveLength(1); |
| 197 | + expect(results[0].warnings[0]).toMatchObject({ line: 2, column: 3, rule: 'block-no-empty' }); |
| 198 | + } finally { |
| 199 | + await rm(isolatedDir, { recursive: true, force: true }); |
| 200 | + } |
| 201 | + }); |
| 202 | + |
181 | 203 | it('standalone with custom syntax as npm package', async () => { |
182 | 204 | const { results } = await standalone({ |
183 | 205 | config: config({ customSyntax: await import('postcss-scss') }), |
@@ -234,7 +256,7 @@ describe('customSyntax set in the config', () => { |
234 | 256 | config: config({ customSyntax: 'unknown-module' }), |
235 | 257 | }), |
236 | 258 | ).rejects.toThrow( |
237 | | - 'Could not find "unknown-module". Do you need to install the package or use the "configBasedir" option?', |
| 259 | + 'Cannot resolve custom syntax module "unknown-module". Check that module "unknown-module" is available and spelled correctly.', |
238 | 260 | ); |
239 | 261 | }); |
240 | 262 |
|
|
0 commit comments