New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@esri/eslint-plugin-calcite-components

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esri/eslint-plugin-calcite-components - npm Package Compare versions

Comparing version 2.0.0-next.0 to 2.0.0-next.1

/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://github.com/Esri/calcite-design-system/blob/2.0.0-next.0/LICENSE.md for details.
See https://github.com/Esri/calcite-design-system/blob/2.0.0-next.1/LICENSE.md for details.
*/
'use strict';
var stencilEslintCore = require('stencil-eslint-core');
var utils = require('@typescript-eslint/utils');
const rule$2 = {
const createRule$2 = utils.ESLintUtils.RuleCreator((name) => name);
var banEvents = createRule$2({
name: "ban-events",
defaultOptions: [],
meta: {
docs: {
description: "This rule catches helps ban or warn against listened event types",
category: "Consistency",
description: "This rule helps ban or warn against listened event types",
},
messages: {
default: "{{message}}",
},
schema: {

@@ -38,8 +43,7 @@ type: "array",

},
create: function (context) {
const stencil = stencilEslintCore.stencilComponentContext();
create(context) {
const bannedEventToMessageLookup = new Map();
context.options.forEach((option) => {
const event = typeof option === "string" ? option : option.event;
const message = typeof option === "string" ? null : option.message ?? null;
const message = typeof option === "string" ? null : (option.message ?? null);
bannedEventToMessageLookup.set(event, message);

@@ -50,30 +54,27 @@ });

}
function checkEvent(node, eventName) {
if (bannedEventToMessageLookup.has(eventName)) {
context.report({
node,
messageId: "default",
data: {
message: buildMessage(eventName),
},
});
}
}
return {
...stencil.rules,
"MethodDefinition > Decorator[expression.callee.name=Listen] Literal": (node) => {
if (stencil.isComponent()) {
const eventName = node.value;
if (bannedEventToMessageLookup.has(eventName)) {
context.report({
node,
message: buildMessage(eventName),
});
}
}
"ClassDeclaration[superClass.name=LitElement] CallExpression:matches([callee.property.name=addEventListener], [callee.property.name=removeEventListener])"(node) {
const eventName = node.arguments[0].value;
checkEvent(node, eventName);
},
"CallExpression:matches([callee.property.name=addEventListener], [callee.property.name=removeEventListener])": (node) => {
if (stencil.isComponent()) {
const eventName = node.arguments[0].value;
if (bannedEventToMessageLookup.has(eventName)) {
context.report({
node,
message: buildMessage(eventName),
});
}
}
"ClassDeclaration[superClass.name=LitElement] CallExpression[callee.object.type=ThisExpression][callee.property.name=listen], CallExpression[callee.object.type=ThisExpression][callee.property.name=listenOn]"(node) {
const eventName = node.arguments[1].value;
checkEvent(node, eventName);
},
};
},
};
});
const createRule$1 = utils.ESLintUtils.RuleCreator((name) => name);
function isCreateElement(node) {

@@ -88,9 +89,13 @@ return (node?.callee?.type === "MemberExpression" &&

}
const rule$1 = {
var noDynamicCreateelement = createRule$1({
name: "no-dynamic-createelement",
defaultOptions: [],
meta: {
docs: {
description: "This ensures supporting components created with `document.createElement()` are auto-defined in Stencil's `components` output target.",
recommended: true,
description: "This rule ensures that calls to `document.createElement()` use string literals to avoid dynamic tag creation to enhance plugin compatibility.",
},
fixable: "code",
messages: {
default: "Calls to document.createElement() should use string literals",
},
schema: [],

@@ -108,3 +113,3 @@ type: "problem",

node,
message: "Calls to document.createElement() should use string literals",
messageId: "default",
});

@@ -115,26 +120,31 @@ }

},
};
});
const rule = {
const createRule = utils.ESLintUtils.RuleCreator((name) => name);
var strictBooleanAttributes = createRule({
name: "strict-boolean-attributes",
meta: {
docs: {
description: "This rule catches Stencil boolean Props that would not be able to be set to false with HTML5-compliant attributes.",
category: "Possible Errors",
recommended: false,
description: "This rule catches boolean properties decorated with @Prop() that are initialized to true.",
},
messages: {
default: "Boolean properties decorated with @property() should not be initialized to true",
},
schema: [],
type: "problem",
},
defaultOptions: [],
create(context) {
const stencil = stencilEslintCore.stencilComponentContext();
return {
...stencil.rules,
PropertyDefinition: (node) => {
const propDecorator = stencilEslintCore.getDecorator(node, "Prop");
if (stencil.isComponent() && propDecorator) {
const initializer = node.value?.value;
if (initializer === true) {
const decorators = node.decorators || [];
const hasPropDecorator = decorators.some((decorator) => decorator.expression.type === "CallExpression" &&
decorator.expression.callee.type === "Identifier" &&
decorator.expression.callee.name === "property");
if (hasPropDecorator) {
const initializer = node.value;
if (initializer && initializer.type === "Literal" && initializer.value === true) {
context.report({
node: node.key,
message: `Boolean properties decorated with @Prop() should not be initialized to true`,
messageId: "default",
});

@@ -146,8 +156,8 @@ }

},
};
});
var index$1 = {
"ban-events": rule$2,
"no-dynamic-createelement": rule$1,
"strict-boolean-attributes": rule,
"ban-events": banEvents,
"no-dynamic-createelement": noDynamicCreateelement,
"strict-boolean-attributes": strictBooleanAttributes,
};

@@ -154,0 +164,0 @@

{
"name": "@esri/eslint-plugin-calcite-components",
"version": "2.0.0-next.0",
"version": "2.0.0-next.1",
"description": "ESLint rules for @esri/calcite-components",

@@ -22,5 +22,2 @@ "repository": {

},
"dependencies": {
"stencil-eslint-core": "0.4.1"
},
"devDependencies": {

@@ -30,2 +27,3 @@ "ts-node": "10.9.2"

"peerDependencies": {
"@typescript-eslint/utils": ">=8.0.0",
"eslint": ">=8.0.0"

@@ -37,3 +35,3 @@ },

},
"gitHead": "3ed2a1cc5e9b6f45bf5826477142d9a4698db73f"
"gitHead": "5cf4cb52b7c2ff69022efcd52f4b22775818b437"
}