mysticatea / eslint4b

ESLint which works in browsers.
MIT License
37 stars 19 forks source link

Infinite loop with "no-useless-escape" rule #8

Open ota-meshi opened 3 years ago

ota-meshi commented 3 years ago

I have confirmed with eslint4b v7.20.0.

The following source code is the source code for at 25,907 line of the eslint4b/dist/core-rules.js file causing the infinite loop.

        while (match = /\\[^\d]/gu.exec(value)) {
          validateString(node, match);
        }

In the original source code, the regular expression correctly uses one instance, so it doesn't go into an infinite loop.

https://github.com/eslint/eslint/blob/87c43a5d7ea2018cffd6d9b5c431ecb60caaf0d6/lib/rules/no-useless-escape.js#L210-L215

                const pattern = /\\[^\d]/gu;
                let match;

                while ((match = pattern.exec(value))) {
                    validateString(node, match);
                }

I think it's probably a build system bug, but I opened an issue here because I don't know which build system is wrong.

ota-meshi commented 3 years ago

Maybe a bug in babel-plugin-minify-dead-code-elimination, but it doesn't seem to be fixed yet.

https://github.com/babel/minify/issues/981