Skip to content

Commit

Permalink
fix(eslint-plugin): [quotes] ignore backticks for interface properties (
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk authored and bradzacher committed Dec 16, 2019
1 parent 348d2f6 commit 3923a09
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 84 deletions.
20 changes: 5 additions & 15 deletions packages/eslint-plugin/src/rules/quotes.ts
@@ -1,7 +1,4 @@
import {
AST_NODE_TYPES,
TSESTree,
} from '@typescript-eslint/experimental-utils';
import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';
import baseRule from 'eslint/lib/rules/quotes';
import * as util from '../util';

Expand Down Expand Up @@ -32,21 +29,14 @@ export default util.createRule<Options, MessageIds>({
create(context, [option]) {
const rules = baseRule.create(context);

const isModuleDeclaration = (node: TSESTree.Literal): boolean => {
return (
!!node.parent && node.parent.type === AST_NODE_TYPES.TSModuleDeclaration
);
};

const isTypeLiteral = (node: TSESTree.Literal): boolean => {
return !!node.parent && node.parent.type === AST_NODE_TYPES.TSLiteralType;
};

return {
Literal(node): void {
const parent = node.parent;
if (
option === 'backtick' &&
(isModuleDeclaration(node) || isTypeLiteral(node))
(parent?.type === AST_NODE_TYPES.TSModuleDeclaration ||
parent?.type === AST_NODE_TYPES.TSLiteralType ||
parent?.type === AST_NODE_TYPES.TSPropertySignature)
) {
return;
}
Expand Down

0 comments on commit 3923a09

Please sign in to comment.