eslint-plugin-use-macros
v4.0.1
Published
ESLint rules for libraries which supports the babel-macros
Downloads
31,268
Readme
eslint-plugin-use-macros
Rule details
This plugin provides the rules to use the babel macros for specific libraries (such as styled-components and graphql-tag.)
- styled-components -> styled-components/macro
- use-macros/styled-components
- graphql-tag -> graphql.macro
- use-macros/graphql-tag
// invalid
import gql from "graphql-tag";
const QUERY = gql`
query getUser {
user {
id
title
}
}
`;
👇
// valid
import { gql } from "graphql.macro";
const QUERY = gql`
query getUser {
user {
id
title
}
}
`;
Installation
npm install --save eslint-plugin-use-macros
# or
yarn add eslint-plugin-use-macros
Usage
With "Flat Config"
import pluginUseMacros from "eslint-plugin-use-macros";
export default [
{
plugins: {
"use-macros": pluginUseMacros,
},
rules: {
"use-macros/styled-components": "error",
},
},
];
With "Legacy Config"
{
"plugins": ["use-macros"],
"rules": {
"use-macros/styled-components": "error"
}
}