Repository: eslint/eslint
File: lib/rules/quotes.js (JavaScript)

Code before:

                if (statement === node.parent) {
                    return true;
                }
                if (!isDirective(statement)) {
                    break;
                }
            }

            return false;
        }

        /**
         * Checks whether or not a given node is allowed as non backtick.
         * @param {ASTNode} node A node to check.
         * @returns {boolean} Whether or not the node is allowed as non backtick.
         * @private
         */
        function isAllowedAsNonBacktick(node) {
            const parent = node.parent;

            switch (parent.type) {

                // Directive Prologues.
                case "ExpressionStatement":
                    return !astUtils.isParenthesised(sourceCode, node) && isExpressionInOrJustAfterDirectivePrologue(node);

                // LiteralPropertyName.
                case "Property":
                case "PropertyDefinition":
                case "MethodDefinition":
                    return parent.key === node && !parent.computed;

                // ModuleSpecifier.
                case "ImportDeclaration":
                case "ExportNamedDeclaration":
                    return parent.source === node;

                // ModuleExportName or ModuleSpecifier.
                case "ExportAllDeclaration":
                    return parent.exported === node || parent.source === node;

                // ModuleExportName.
                case "ImportSpecifier":
                    return parent.imported === node;

                // ModuleExportName.
                case "ExportSpecifier":
                    return parent.local === node || parent.exported === node;

                // Others don't allow.

Review comment (refactor):
This checking for parentheses can produce more lint errors in existing code:

```js
/* eslint quotes: ["error", "backtick"] */

("use strict") // error after this change

```

So we should tag this as `feat:` per our semver polices. However, since the PR is about no-extra-parens, and this change isn't just refactoring, it might be better to extract all changes to the quotes rule into a separate PR?

Code after:
                if (statement === node.parent) {
                    return true;
                }
                if (!isDirective(statement)) {
                    break;
                }
            }

            return false;
        }

        /**
         * Checks whether or not a given node is allowed as non backtick.
         * @param {ASTNode} node A node to check.
         * @returns {boolean} Whether or not the node is allowed as non backtick.
         * @private
         */
        function isAllowedAsNonBacktick(node) {
            const parent = node.parent;

            switch (parent.type) {

                // Directive Prologues.
                case "ExpressionStatement":
                    return isPartOfDirectivePrologue(node);

                // LiteralPropertyName.
                case "Property":
                case "PropertyDefinition":
                case "MethodDefinition":
                    return parent.key === node && !parent.computed;

                // ModuleSpecifier.
                case "ImportDeclaration":
                case "ExportNamedDeclaration":
                    return parent.source === node;

                // ModuleExportName or ModuleSpecifier.
                case "ExportAllDeclaration":
                    return parent.exported === node || parent.source === node;

                // ModuleExportName.
                case "ImportSpecifier":
                    return parent.imported === node;

                // ModuleExportName.
                case "ExportSpecifier":
                    return parent.local === node || parent.exported === node;

                // Others don't allow.
                default: