|
1 | 1 | import stylelint, { type LinterOptions, getConfigForFile } from 'stylelint'; |
2 | 2 |
|
3 | 3 | // Run Stylelint Programmatically |
4 | | -export async function lintStyles(opt: Omit<LinterOptions, 'formatter'>) { |
| 4 | +export async function lintStyles({config, ...options}: Omit<LinterOptions, 'formatter'>) { |
5 | 5 | console.log('Stylelint props:', Object.keys(stylelint)); |
6 | 6 |
|
7 | | - const _linter = stylelint._createLinter(opt); |
8 | 7 | //console.log('Stylelint._createLinter:', Object.keys(_linter)); |
9 | 8 | //console.log('Stylelint._createLinter._extendExplorer:', _linter._extendExplorer); |
10 | 9 | //console.log('Stylelint._createLinter._extendExplorer.load():', await _linter._extendExplorer.load(opt.configFile ?? '')); |
11 | | - console.log('Stylelint._createLinter.resolveConfig:', await getConfigForFile(opt.configFile ?? '', { |
12 | | - configFile: opt.configFile, |
13 | | - configBasedir: opt.configBasedir, |
14 | | - config: opt.config, |
15 | | - cwd: opt.cwd, |
16 | | - })); |
| 10 | + const _linter = stylelint._createLinter(options); |
| 11 | + const results = await getConfigForFile(_linter, options.configFile ?? '') |
| 12 | + console.log('Stylelint._createLinter.resolveConfig:', results.config); |
17 | 13 |
|
18 | 14 |
|
19 | 15 | try { |
20 | 16 | // eslint-disable-next-line functional/immutable-data |
21 | 17 | globalThis.console.assert = globalThis.console.assert || (() => {}); |
22 | 18 | const { results } = await stylelint.lint({ |
23 | | - ...opt, |
| 19 | + ...options, |
24 | 20 | formatter: 'json', |
25 | 21 | }); |
26 | 22 | return results; |
|
0 commit comments