@esri/eslint-plugin-calcite-components
Advanced tools
Comparing version 0.2.3-next.4 to 0.2.3-next.5
/* | ||
All material copyright ESRI, All Rights Reserved, unless otherwise specified. | ||
See https://github.com/Esri/calcite-design-system/blob/0.2.3-next.3/LICENSE.md for details. | ||
See https://github.com/Esri/calcite-design-system/blob/0.2.3-next.4/LICENSE.md for details. | ||
*/ | ||
@@ -9,3 +9,3 @@ 'use strict'; | ||
const rule$3 = { | ||
const rule$4 = { | ||
meta: { | ||
@@ -84,3 +84,3 @@ docs: { | ||
eventHandlerPropLikePattern.test(attributeName); | ||
const rule$2 = { | ||
const rule$3 = { | ||
meta: { | ||
@@ -123,2 +123,36 @@ docs: { | ||
const rule$2 = { | ||
meta: { | ||
docs: { | ||
description: `This ensures the node passed into the ref callback is in sync with its JSX attributes/properties when invoked.`, | ||
recommended: true, | ||
}, | ||
fixable: "code", | ||
schema: [], | ||
type: "problem", | ||
}, | ||
create(context) { | ||
return { | ||
JSXIdentifier(node) { | ||
const openingElement = node.parent; | ||
if (openingElement.type === "JSXOpeningElement") { | ||
const attributes = []; | ||
openingElement.attributes.forEach((attr) => { | ||
if (attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier") { | ||
attributes.push(attr.name.name); | ||
} | ||
}); | ||
const refAttribute = attributes.find((attr) => attr === "ref"); | ||
if (refAttribute && attributes.indexOf(refAttribute) !== attributes.length - 1) { | ||
context.report({ | ||
node, | ||
message: `"ref" prop should be placed last in JSX to ensure the node attrs/props are in sync.`, | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
}, | ||
}; | ||
// @ts-ignore | ||
@@ -196,6 +230,7 @@ const rule$1 = { | ||
var index$1 = { | ||
"ban-events": rule$3, | ||
"ban-props-on-host": rule$2, | ||
"ban-events": rule$4, | ||
"ban-props-on-host": rule$3, | ||
"enforce-ref-last-prop": rule$2, | ||
"require-event-emitter-type": rule$1, | ||
"strict-boolean-attributes": rule | ||
"strict-boolean-attributes": rule, | ||
}; | ||
@@ -212,8 +247,8 @@ | ||
ecmaFeatures: { | ||
jsx: true | ||
} | ||
jsx: true, | ||
}, | ||
}, | ||
env: { | ||
es2020: true, | ||
browser: true | ||
browser: true, | ||
}, | ||
@@ -223,7 +258,8 @@ plugins: ["@esri/calcite-components"], | ||
"@esri/calcite-components/ban-props-on-host": 2, | ||
"@esri/calcite-components/enforce-ref-last-prop": 2, | ||
"@esri/calcite-components/require-event-emitter-type": 2, | ||
"@esri/calcite-components/strict-boolean-attributes": 2 | ||
} | ||
} | ||
] | ||
"@esri/calcite-components/strict-boolean-attributes": 2, | ||
}, | ||
}, | ||
], | ||
}; | ||
@@ -235,5 +271,6 @@ | ||
"@esri/calcite-components/ban-props-on-host": 2, | ||
"@esri/calcite-components/enforce-ref-last-prop": 2, | ||
"@esri/calcite-components/require-event-emitter-type": 2, | ||
"@esri/calcite-components/strict-boolean-attributes": 2 | ||
} | ||
"@esri/calcite-components/strict-boolean-attributes": 2, | ||
}, | ||
}; | ||
@@ -240,0 +277,0 @@ |
{ | ||
"name": "@esri/eslint-plugin-calcite-components", | ||
"version": "0.2.3-next.4", | ||
"version": "0.2.3-next.5", | ||
"description": "ESLint rules for @esri/calcite-components", | ||
@@ -27,3 +27,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "7e40a34d226917809df76c3a15047071d051756f" | ||
"gitHead": "4ef8b6730d9aac8b11e46feac71dd563990139e5" | ||
} |
@@ -38,3 +38,3 @@ # @esri/eslint-plugin-calcite-components | ||
``` | ||
```shell | ||
npm run lint | ||
@@ -53,2 +53,6 @@ ``` | ||
- [`@esri/calcite-components/enforce-ref-last-prop`](./docs/enforce-ref-last-prop.md) | ||
This ensures the node passed into the `ref` callback is in sync with its JSX attributes/properties when invoked. | ||
- [`@esri/calcite-components/require-event-emitter-type`](./docs/require-event-emitter-type.md) | ||
@@ -67,2 +71,3 @@ | ||
"@esri/calcite-components/ban-props-on-host": "error", | ||
"@esri/calcite-components/enforce-ref-last-prop": "error", | ||
"@esri/calcite-components/require-event-emitter-type": "error", | ||
@@ -89,2 +94,2 @@ "@esri/calcite-components/strict-boolean-attributes": "error" | ||
email: contracts@esri.com | ||
email: <contracts@esri.com> |
14019
266
92