Skip to content

Commit

Permalink
feat: hide warning on no plugins (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-Bernardito committed Sep 23, 2020
1 parent 52412f6 commit dd52931
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Expand Up @@ -157,6 +157,7 @@ export default async function loader(content, map, meta) {

try {
result = await postcss(plugins).process(content, {
hideNothingWarning: true,
from: resourcePath,
to: resourcePath,
map: options.sourceMap
Expand Down
24 changes: 24 additions & 0 deletions test/loader.test.js
Expand Up @@ -449,4 +449,28 @@ describe('loader', () => {
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

// TODO unskip after updating postcss to 8 version
it.skip('should not generate console.warn when plugins disabled and hideNothingWarning is "true"', async () => {
jest.spyOn(console, 'warn').mockImplementation(() => {});

const compiler = getCompiler('./empty.js', {
import: false,
url: false,
});
const stats = await compile(compiler);

// eslint-disable-next-line no-console
expect(console.warn).not.toHaveBeenCalledWith(
'You did not set any plugins, parser, or stringifier. ' +
'Right now, PostCSS does nothing. Pick plugins for your case ' +
'on https://www.postcss.parts/ and use them in postcss.config.js.'
);
expect(getModuleSource('./empty.css', stats)).toMatchSnapshot('module');
expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot(
'result'
);
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});
});

0 comments on commit dd52931

Please sign in to comment.