@compiled/eslint-plugin
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -14,3 +14,4 @@ export declare const recommended: { | ||
'@compiled/no-suppress-xcss': string; | ||
'@compiled/no-empty-styled-expression': string; | ||
}; | ||
}; |
@@ -17,4 +17,5 @@ "use strict"; | ||
'@compiled/no-suppress-xcss': 'error', | ||
'@compiled/no-empty-styled-expression': 'error', | ||
}, | ||
}; | ||
//# sourceMappingURL=recommended.js.map |
@@ -29,4 +29,5 @@ export declare const rules: { | ||
'@compiled/no-suppress-xcss': string; | ||
'@compiled/no-empty-styled-expression': string; | ||
}; | ||
}; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isStyled = void 0; | ||
const constants_1 = require("../../utils/constants"); | ||
const isStyledImportSpecifier = (def) => { | ||
var _a, _b; | ||
return def.node.type === 'ImportSpecifier' && | ||
def.node.imported.type === 'Identifier' && | ||
def.node.imported.name === 'styled' && | ||
((_a = def.parent) === null || _a === void 0 ? void 0 : _a.type) === 'ImportDeclaration' && | ||
((_b = def.parent) === null || _b === void 0 ? void 0 : _b.source.value) === constants_1.COMPILED_IMPORT; | ||
}; | ||
const styled_import_1 = require("../../utils/styled-import"); | ||
const isStyled = (node, references) => (node.type === 'MemberExpression' && | ||
@@ -18,3 +10,3 @@ node.object.type === 'Identifier' && | ||
return reference.identifier === node.object && | ||
((_a = reference.resolved) === null || _a === void 0 ? void 0 : _a.defs.some(isStyledImportSpecifier)); | ||
((_a = reference.resolved) === null || _a === void 0 ? void 0 : _a.defs.some(styled_import_1.isStyledImportSpecifier)); | ||
})) || | ||
@@ -26,5 +18,5 @@ (node.type === 'CallExpression' && | ||
return reference.identifier === node.callee && | ||
((_a = reference.resolved) === null || _a === void 0 ? void 0 : _a.defs.some(isStyledImportSpecifier)); | ||
((_a = reference.resolved) === null || _a === void 0 ? void 0 : _a.defs.some(styled_import_1.isStyledImportSpecifier)); | ||
})); | ||
exports.isStyled = isStyled; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@compiled/eslint-plugin", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "A familiar and performant compile time CSS-in-JS library for React.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://compiledcssinjs.com/docs/pkg-eslint-plugin", |
@@ -14,3 +14,4 @@ export const recommended = { | ||
'@compiled/no-suppress-xcss': 'error', | ||
'@compiled/no-empty-styled-expression': 'error', | ||
}, | ||
}; |
# `jsx-pragma` | ||
Ensure that the Compiled JSX pragma is set when using the `css` or `xcss` prop. | ||
Ensure that the Compiled JSX pragma is set when using the `css` prop. | ||
@@ -19,3 +19,3 @@ A JSX pragma is a comment that declares where to import the JSX namespace from. It looks | ||
For all Compiled usages, one of these should be used. See the | ||
[Emotion documentation](https://emotion.sh/docs/css-prop#jsx-pragma) for more details | ||
[Babel documentation](https://babeljs.io/docs/babel-plugin-transform-react-jsx) for more details | ||
on how JSX pragmas work. | ||
@@ -57,11 +57,2 @@ | ||
```js | ||
// [{ "pragma": "jsxImportSource" }] | ||
import { Box } from '@atlaskit/primitives'; | ||
<Box xcss={{ borderStyle: 'solid' }} />; | ||
^^^ missing pragma | ||
``` | ||
```js | ||
// [{ "detectConflictWithOtherLibraries": true }] | ||
@@ -68,0 +59,0 @@ |
import type { Rule, Scope } from 'eslint'; | ||
import { COMPILED_IMPORT } from '../../utils/constants'; | ||
import { isStyledImportSpecifier } from '../../utils/styled-import'; | ||
type Definition = Scope.Definition; | ||
type Node = Rule.Node; | ||
type Reference = Scope.Reference; | ||
const isStyledImportSpecifier = (def: Definition) => | ||
def.node.type === 'ImportSpecifier' && | ||
def.node.imported.type === 'Identifier' && | ||
def.node.imported.name === 'styled' && | ||
def.parent?.type === 'ImportDeclaration' && | ||
def.parent?.source.value === COMPILED_IMPORT; | ||
export const isStyled = (node: Node, references: Reference[]): boolean => | ||
@@ -17,0 +9,0 @@ (node.type === 'MemberExpression' && |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
399124
160
9592