Skip to content

Commit

Permalink
Fix with workaround a TypeError thrown for "html"
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 committed May 21, 2020
1 parent 6cfea29 commit ca76608
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/__tests__/fixtures/html.js
@@ -0,0 +1,5 @@
'use strict';

let html;

html.replace();
13 changes: 13 additions & 0 deletions lib/__tests__/standalone-syntax.test.js
Expand Up @@ -238,6 +238,19 @@ it('standalone with automatic syntax inference', () => {
});
});

it('standalone with js file contains html', () => {
return standalone({
files: `${fixturesPath}/html.js`,
config: {
rules: {
'block-no-empty': true,
},
},
}).then((data) => {
expect(data.results[0].errored).toBe(false);
});
});

it('standalone with postcss-safe-parser', () => {
return standalone({
files: `${fixturesPath}/syntax_error.*`,
Expand Down
5 changes: 4 additions & 1 deletion lib/syntaxes/index.js
Expand Up @@ -7,7 +7,10 @@ const importLazy = require('import-lazy')(require);
/** @type {{[k: string]: Syntax}} */
module.exports = {
'css-in-js': importLazy('./syntax-css-in-js'),
html: importLazy('./syntax-html'),
// TODO: investigate why lazy import HTML syntax causes
// JS files with the word "html" to throw TypeError
// https://github.com/stylelint/stylelint/issues/4793
// html: importLazy('./syntax-html'),
less: importLazy('./syntax-less'),
markdown: importLazy('./syntax-markdown'),
sass: importLazy('./syntax-sass'),
Expand Down

0 comments on commit ca76608

Please sign in to comment.