first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_author_email_still_default_exports = {};
__export(community_package_json_author_email_still_default_exports, {
default: () => community_package_json_author_email_still_default_default
});
module.exports = __toCommonJS(community_package_json_author_email_still_default_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var import_constants = require("../constants");
var import_defaultValue = require("../ast/utils/defaultValue");
var import_ast = require("../ast");
var community_package_json_author_email_still_default_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
defaultOptions: [{ authorEmail: import_constants.COMMUNITY_PACKAGE_JSON.AUTHOR_EMAIL }],
meta: {
type: "problem",
docs: {
description: import_ast.docline`The \`author.email\` value in the \`package.json\` of a community package must be different from the default value ${import_constants.COMMUNITY_PACKAGE_JSON.AUTHOR_EMAIL} or a user-defined default.`,
recommended: "strict"
},
schema: [
{
type: "object",
properties: {
authorEmail: {
type: "string"
}
},
additionalProperties: false
}
],
messages: {
updateAuthorEmail: "Update the `author.email` key in package.json"
}
},
create(context, options) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const author = import_getters.getters.communityPackageJson.getAuthor(node);
if (!author)
return;
const authorEmail = getAuthorEmail(author);
if (authorEmail === null)
return;
const defaultAuthorEmail = (0, import_defaultValue.getDefaultValue)(options, "authorEmail");
if (authorEmail === defaultAuthorEmail) {
context.report({
messageId: "updateAuthorEmail",
node
});
}
}
};
}
});
function getAuthorEmail(author) {
if (author.ast.type === import_utils2.AST_NODE_TYPES.Property && author.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
const authorEmail = author.ast.value.properties.find(import_identifiers.id.hasEmailLiteral);
if (authorEmail === void 0)
return null;
if (authorEmail.type === import_utils2.AST_NODE_TYPES.Property && authorEmail.value.type === import_utils2.AST_NODE_TYPES.Literal && typeof authorEmail.value.value === "string") {
return authorEmail.value.value;
}
}
return null;
}

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_author_missing_exports = {};
__export(community_package_json_author_missing_exports, {
default: () => community_package_json_author_missing_default
});
module.exports = __toCommonJS(community_package_json_author_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_author_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `author` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addAuthor: "Add an `author` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getAuthor(node)) {
context.report({
messageId: "addAuthor",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_author_name_missing_exports = {};
__export(community_package_json_author_name_missing_exports, {
default: () => community_package_json_author_name_missing_default
});
module.exports = __toCommonJS(community_package_json_author_name_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var community_package_json_author_name_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `author.name` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addAuthorName: "Add an `author.name` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const author = import_getters.getters.communityPackageJson.getAuthor(node);
if (!author)
return;
if (!hasAuthorName(author)) {
context.report({
messageId: "addAuthorName",
node
});
}
}
};
}
});
function hasAuthorName(author) {
if (author.ast.type === import_utils2.AST_NODE_TYPES.Property && author.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
return author.ast.value.properties.some(import_identifiers.id.hasNameLiteral);
}
return false;
}

View File

@@ -0,0 +1,87 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_author_name_still_default_exports = {};
__export(community_package_json_author_name_still_default_exports, {
default: () => community_package_json_author_name_still_default_default
});
module.exports = __toCommonJS(community_package_json_author_name_still_default_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var import_constants = require("../constants");
var import_defaultValue = require("../ast/utils/defaultValue");
var import_ast = require("../ast");
var community_package_json_author_name_still_default_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
defaultOptions: [{ authorName: import_constants.COMMUNITY_PACKAGE_JSON.AUTHOR_NAME }],
meta: {
type: "problem",
docs: {
description: import_ast.docline`The \`author.name\` value in the \`package.json\` of a community package must be different from the default value ${import_constants.COMMUNITY_PACKAGE_JSON.AUTHOR_NAME} or a user-defined default.`,
recommended: "strict"
},
schema: [
{
type: "object",
properties: {
authorName: {
type: "string"
}
},
additionalProperties: false
}
],
messages: {
updateAuthorName: "Update the `author.name` key in package.json"
}
},
create(context, options) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const author = import_getters.getters.communityPackageJson.getAuthor(node);
if (!author)
return;
const authorName = getAuthorName(author);
if (authorName === null)
return;
const defaultAuthorName = (0, import_defaultValue.getDefaultValue)(options, "authorName");
if (authorName === defaultAuthorName) {
context.report({
messageId: "updateAuthorName",
node
});
}
}
};
}
});
function getAuthorName(author) {
if (author.ast.type === import_utils2.AST_NODE_TYPES.Property && author.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
const authorName = author.ast.value.properties.find(import_identifiers.id.hasNameLiteral);
if (authorName === void 0)
return null;
if (authorName.type === import_utils2.AST_NODE_TYPES.Property && authorName.value.type === import_utils2.AST_NODE_TYPES.Literal && typeof authorName.value.value === "string") {
return authorName.value.value;
}
}
return null;
}

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_description_missing_exports = {};
__export(community_package_json_description_missing_exports, {
default: () => community_package_json_description_missing_default
});
module.exports = __toCommonJS(community_package_json_description_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_description_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `description` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addDescription: "Add a `description` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getDescription(node)) {
context.report({
messageId: "addDescription",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_description_still_default_exports = {};
__export(community_package_json_description_still_default_exports, {
default: () => community_package_json_description_still_default_default
});
module.exports = __toCommonJS(community_package_json_description_still_default_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_constants = require("../constants");
var import_defaultValue = require("../ast/utils/defaultValue");
var import_ast = require("../ast");
var community_package_json_description_still_default_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
defaultOptions: [{ description: import_constants.COMMUNITY_PACKAGE_JSON.DESCRIPTION }],
meta: {
type: "problem",
docs: {
description: import_ast.docline`The \`description\` value in the \`package.json\` of a community package must be different from the default value ${import_constants.COMMUNITY_PACKAGE_JSON.DESCRIPTION} or a user-defined default.`,
recommended: "strict"
},
schema: [
{
type: "object",
properties: {
description: {
type: "string"
}
},
additionalProperties: false
}
],
messages: {
updateDescription: "Update the `description` key in package.json"
}
},
create(context, options) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const description = import_getters.getters.communityPackageJson.getDescription(node);
if (!description)
return;
const defaultDescription = (0, import_defaultValue.getDefaultValue)(options, "description");
if (description.value === defaultDescription) {
context.report({
messageId: "updateDescription",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_keywords_missing_exports = {};
__export(community_package_json_keywords_missing_exports, {
default: () => community_package_json_keywords_missing_default
});
module.exports = __toCommonJS(community_package_json_keywords_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_keywords_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `keywords` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addKeywords: "Add a `keywords` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getKeywords(node)) {
context.report({
messageId: "addKeywords",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,68 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_keywords_without_official_tag_exports = {};
__export(community_package_json_keywords_without_official_tag_exports, {
default: () => community_package_json_keywords_without_official_tag_default
});
module.exports = __toCommonJS(community_package_json_keywords_without_official_tag_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_constants = require("../constants");
var import_utils2 = require("@typescript-eslint/utils");
var community_package_json_keywords_without_official_tag_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `The \`keywords\` value in the \`package.json\` of a community package must be an array containing the value \`'${import_constants.COMMUNITY_PACKAGE_JSON.OFFICIAL_TAG}'\`.`,
recommended: "strict"
},
schema: [],
messages: {
addOfficialTag: `Add \`${import_constants.COMMUNITY_PACKAGE_JSON.OFFICIAL_TAG}\` to \`keywords\` in package.json`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const keywords = import_getters.getters.communityPackageJson.getKeywords(node);
if (!keywords)
return;
if (!hasOfficialTag(keywords)) {
context.report({
messageId: "addOfficialTag",
node
});
}
}
};
}
});
function hasOfficialTag(keywords) {
if (keywords.ast.type === import_utils2.AST_NODE_TYPES.Property && keywords.ast.value.type === import_utils2.AST_NODE_TYPES.ArrayExpression) {
return keywords.ast.value.elements.some(
(element) => element?.type === import_utils2.AST_NODE_TYPES.Literal && element.value === import_constants.COMMUNITY_PACKAGE_JSON.OFFICIAL_TAG
);
}
return false;
}

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_license_missing_exports = {};
__export(community_package_json_license_missing_exports, {
default: () => community_package_json_license_missing_default
});
module.exports = __toCommonJS(community_package_json_license_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_license_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `description` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addLicense: "Add a `license` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getLicense(node)) {
context.report({
messageId: "addLicense",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,59 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_license_not_default_exports = {};
__export(community_package_json_license_not_default_exports, {
default: () => community_package_json_license_not_default_default
});
module.exports = __toCommonJS(community_package_json_license_not_default_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_constants = require("../constants");
var community_package_json_license_not_default_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `The \`license\` key in the \`package.json\` of a community package must be the default value \`${import_constants.COMMUNITY_PACKAGE_JSON.LICENSE}\`.`,
recommended: "strict"
},
schema: [],
messages: {
updateLicense: `Update the \`license\` key to ${import_constants.COMMUNITY_PACKAGE_JSON.LICENSE} in package.json`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const license = import_getters.getters.communityPackageJson.getLicense(node);
if (!license)
return;
if (license.value !== import_constants.COMMUNITY_PACKAGE_JSON.LICENSE) {
context.report({
messageId: "updateLicense",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_n8n_api_version_missing_exports = {};
__export(community_package_json_n8n_api_version_missing_exports, {
default: () => community_package_json_n8n_api_version_missing_default
});
module.exports = __toCommonJS(community_package_json_n8n_api_version_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var community_package_json_n8n_api_version_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `n8n.n8nNodesApiVersion` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addN8nNodesApiVersion: "Add an `n8n.n8nNodesApiVersion` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const n8n = import_getters.getters.communityPackageJson.getN8n(node);
if (!n8n)
return;
if (!hasN8nNodesApiVersion(n8n)) {
context.report({
messageId: "addN8nNodesApiVersion",
node
});
}
}
};
}
});
function hasN8nNodesApiVersion(n8n) {
if (n8n.ast.type === import_utils2.AST_NODE_TYPES.Property && n8n.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
return n8n.ast.value.properties.some(import_identifiers.id.hasNodesApiVersion);
}
return false;
}

View File

@@ -0,0 +1,71 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_n8n_api_version_not_number_exports = {};
__export(community_package_json_n8n_api_version_not_number_exports, {
default: () => community_package_json_n8n_api_version_not_number_default
});
module.exports = __toCommonJS(community_package_json_n8n_api_version_not_number_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var community_package_json_n8n_api_version_not_number_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `n8n.n8nNodesApiVersion` value in the `package.json` of a community package must be a number.",
recommended: "strict"
},
schema: [],
messages: {
changeToNumber: "Change the `n8n.n8nNodesApiVersion` value to number in package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const n8n = import_getters.getters.communityPackageJson.getN8n(node);
if (!n8n)
return;
const apiVersion = getN8nNodesApiVersion(n8n);
if (!apiVersion)
return;
if (!hasNumberValue(apiVersion)) {
context.report({
messageId: "changeToNumber",
node
});
}
}
};
}
});
function getN8nNodesApiVersion(n8n) {
if (n8n.ast.type === import_utils2.AST_NODE_TYPES.Property && n8n.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
return n8n.ast.value.properties.find(import_identifiers.id.hasNodesApiVersion) ?? null;
}
return null;
}
function hasNumberValue(n8nNodesApiVersion) {
return n8nNodesApiVersion.type === import_utils2.AST_NODE_TYPES.Property && n8nNodesApiVersion.value.type === import_utils2.AST_NODE_TYPES.Literal && typeof n8nNodesApiVersion.value.value === "number";
}

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_n8n_missing_exports = {};
__export(community_package_json_n8n_missing_exports, {
default: () => community_package_json_n8n_missing_default
});
module.exports = __toCommonJS(community_package_json_n8n_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_n8n_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `n8n` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addN8n: "Add an `n8n` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getN8n(node)) {
context.report({
messageId: "addN8n",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_n8n_nodes_empty_exports = {};
__export(community_package_json_n8n_nodes_empty_exports, {
default: () => community_package_json_n8n_nodes_empty_default
});
module.exports = __toCommonJS(community_package_json_n8n_nodes_empty_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var community_package_json_n8n_nodes_empty_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `n8n.nodes` value in the `package.json` of a community package must contain at least one filepath.",
recommended: "strict"
},
schema: [],
messages: {
addOneFilepath: "Enter at least one filepath in `n8n.nodes` in package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const n8n = import_getters.getters.communityPackageJson.getN8n(node);
if (!n8n)
return;
if (!hasAtLeastOneFilepath(n8n)) {
context.report({
messageId: "addOneFilepath",
node
});
}
}
};
}
});
function hasAtLeastOneFilepath(n8n) {
if (n8n.ast.type === import_utils2.AST_NODE_TYPES.Property && n8n.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
const nodes = n8n.ast.value.properties.find(import_identifiers.id.hasNodesLiteral);
if (!nodes)
return false;
if (nodes.type === import_utils2.AST_NODE_TYPES.Property && nodes.value.type === import_utils2.AST_NODE_TYPES.ArrayExpression) {
return nodes.value.elements.some(
(element) => element?.type === import_utils2.AST_NODE_TYPES.Literal
);
}
}
return null;
}

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_n8n_nodes_missing_exports = {};
__export(community_package_json_n8n_nodes_missing_exports, {
default: () => community_package_json_n8n_nodes_missing_default
});
module.exports = __toCommonJS(community_package_json_n8n_nodes_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var community_package_json_n8n_nodes_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `n8n.nodes` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addN8nNodes: "Add an `n8n.nodes` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const n8n = import_getters.getters.communityPackageJson.getN8n(node);
if (!n8n)
return;
if (!hasN8nNodes(n8n)) {
context.report({
messageId: "addN8nNodes",
node
});
}
}
};
}
});
function hasN8nNodes(n8n) {
if (n8n.ast.type === import_utils2.AST_NODE_TYPES.Property && n8n.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
return n8n.ast.value.properties.some(import_identifiers.id.hasNodesLiteral);
}
return false;
}

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_name_missing_exports = {};
__export(community_package_json_name_missing_exports, {
default: () => community_package_json_name_missing_default
});
module.exports = __toCommonJS(community_package_json_name_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_name_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `name` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addName: "Add a `name` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getName(node)) {
context.report({
messageId: "addName",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,78 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_name_still_default_exports = {};
__export(community_package_json_name_still_default_exports, {
default: () => community_package_json_name_still_default_default
});
module.exports = __toCommonJS(community_package_json_name_still_default_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_constants = require("../constants");
var import_defaultValue = require("../ast/utils/defaultValue");
const isTestRun = process.env.NODE_ENV === "test";
const isProdRun = !isTestRun;
var community_package_json_name_still_default_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
defaultOptions: [{ name: import_constants.COMMUNITY_PACKAGE_JSON.NAME }],
meta: {
type: "problem",
docs: {
description: `The \`name\` key in the \`package.json\` of a community package must be different from the default value \`${import_constants.COMMUNITY_PACKAGE_JSON.NAME}\` or a user-defined default.`,
recommended: "strict"
},
schema: [
{
type: "object",
properties: {
name: {
type: "string"
}
},
additionalProperties: false
}
],
messages: {
updateName: "Update the `name` key in package.json"
}
},
create(context, options) {
return {
ObjectExpression(node) {
const filename = context.getFilename();
if (isProdRun && !filename.includes("package.json"))
return;
if (isProdRun && !import_identifiers.id.prod.isTopLevelObjectExpression(node))
return;
if (isTestRun && !import_identifiers.id.test.isTopLevelObjectExpression(node))
return;
const name = import_getters.getters.communityPackageJson.getName(node);
if (!name)
return;
const defaultName = (0, import_defaultValue.getDefaultValue)(options, "name");
if (name.value === defaultName) {
context.report({
messageId: "updateName",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,89 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_repository_url_still_default_exports = {};
__export(community_package_json_repository_url_still_default_exports, {
default: () => community_package_json_repository_url_still_default_default
});
module.exports = __toCommonJS(community_package_json_repository_url_still_default_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var import_utils2 = require("@typescript-eslint/utils");
var import_constants = require("../constants");
var import_defaultValue = require("../ast/utils/defaultValue");
var import_ast = require("../ast");
var community_package_json_repository_url_still_default_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
defaultOptions: [{ repositoryUrl: import_constants.COMMUNITY_PACKAGE_JSON.REPOSITORY_URL }],
meta: {
type: "problem",
docs: {
description: import_ast.docline`The \`repository.url\` value in the \`package.json\` of a community package must be different from the default value \`${import_constants.COMMUNITY_PACKAGE_JSON.REPOSITORY_URL}\` or a user-defined default.`,
recommended: "strict"
},
schema: [
{
type: "object",
properties: {
repositoryUrl: {
type: "string"
}
},
additionalProperties: false
}
],
messages: {
updateRepositoryUrl: "Update the `repository.url` key in package.json"
}
},
create(context, options) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
const repository = import_getters.getters.communityPackageJson.getRepository(node);
if (!repository)
return;
const repositoryUrl = getRepositoryUrl(repository);
if (!repositoryUrl)
return;
const defaultRepositoryUrl = (0, import_defaultValue.getDefaultValue)(options, "repositoryUrl");
if (repositoryUrl === defaultRepositoryUrl) {
context.report({
messageId: "updateRepositoryUrl",
node
});
}
}
};
}
});
function getRepositoryUrl(repository) {
if (repository.ast.type === import_utils2.AST_NODE_TYPES.Property && repository.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
const repositoryUrl = repository.ast.value.properties.find(
import_identifiers.id.hasUrlLiteral
);
if (!repositoryUrl)
return null;
if (repositoryUrl.type === import_utils2.AST_NODE_TYPES.Property && repositoryUrl.value.type === import_utils2.AST_NODE_TYPES.Literal && typeof repositoryUrl.value.value === "string") {
return repositoryUrl.value.value;
}
}
return null;
}

View File

@@ -0,0 +1,55 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var community_package_json_version_missing_exports = {};
__export(community_package_json_version_missing_exports, {
default: () => community_package_json_version_missing_default
});
module.exports = __toCommonJS(community_package_json_version_missing_exports);
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils = require("../ast/utils");
var community_package_json_version_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `version` key must be present in the `package.json` of a community package.",
recommended: "strict"
},
schema: [],
messages: {
addVersion: "Add a `version` key to package.json"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isCommunityPackageJson(context.getFilename(), node))
return;
if (!import_getters.getters.communityPackageJson.getVersion(node)) {
context.report({
messageId: "addVersion",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,80 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_authenticate_type_assertion_exports = {};
__export(cred_class_field_authenticate_type_assertion_exports, {
default: () => cred_class_field_authenticate_type_assertion_default
});
module.exports = __toCommonJS(cred_class_field_authenticate_type_assertion_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var cred_class_field_authenticate_type_assertion_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "In a credential class, the field `authenticate` must be typed `IAuthenticateGeneric`",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeAssertionAndType: "Remove assertion and type field `authenticate` with `IAuthenticateGeneric` [autofixable]",
removeAssertion: "Remove assertion [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
TSAsExpression(node) {
if (!import_utils2.utils.isCredentialFile(context.getFilename()))
return;
if (node.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "IAuthenticateGeneric" && node.parent !== void 0 && node.parent.type === import_utils.AST_NODE_TYPES.PropertyDefinition && node.parent.key.type === import_utils.AST_NODE_TYPES.Identifier && node.parent.key.name === "authenticate") {
const removalNode = node.typeAnnotation.typeName;
const insertionNode = node.parent.key;
const rangeToRemove = import_utils2.utils.getRangeOfAssertion(removalNode);
if (isAlreadyTyped(insertionNode)) {
return context.report({
messageId: "removeAssertion",
node,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
context.report({
messageId: "removeAssertionAndType",
node,
fix: (fixer) => {
return [
fixer.removeRange(rangeToRemove),
fixer.insertTextAfterRange(
insertionNode.range,
": IAuthenticateGeneric"
)
];
}
});
}
}
};
}
});
function isAlreadyTyped(node) {
if (!node.typeAnnotation)
return false;
return node.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSTypeAnnotation && node.typeAnnotation.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSArrayType && node.typeAnnotation.typeAnnotation.elementType.type === import_utils.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeAnnotation.elementType.typeName.type === import_utils.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeAnnotation.elementType.typeName.name === "IAuthenticateGeneric";
}

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_display_name_miscased_exports = {};
__export(cred_class_field_display_name_miscased_exports, {
default: () => cred_class_field_display_name_miscased_default
});
module.exports = __toCommonJS(cred_class_field_display_name_miscased_exports);
var import_title_case = require("title-case");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_display_name_miscased_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`displayName` field in credential class must be title cased, except for `n8n API` and `E-goi API`",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useTitleCase: "Change to title case [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const displayName = import_getters.getters.credClassBody.getDisplayName(node.body);
if (!displayName || EXCEPTIONS.includes(displayName.value))
return;
if (displayName.value !== (0, import_title_case.titleCase)(displayName.value)) {
context.report({
messageId: "useTitleCase",
node: displayName.ast,
fix: (fixer) => fixer.replaceText(
displayName.ast,
`displayName = '${(0, import_title_case.titleCase)(displayName.value)}';`
)
});
}
}
};
}
});
const EXCEPTIONS = ["n8n API", "E-goi API"];

View File

@@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_display_name_missing_api_exports = {};
__export(cred_class_field_display_name_missing_api_exports, {
default: () => cred_class_field_display_name_missing_api_default
});
module.exports = __toCommonJS(cred_class_field_display_name_missing_api_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_apiSuffixExemption = require("../ast/utils/apiSuffixExemption");
var cred_class_field_display_name_missing_api_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`displayName` field in credential class must be end with `API`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixSuffix: "Append 'API' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
if ((0, import_apiSuffixExemption.isExemptedFromApiSuffix)(context.getFilename()))
return;
const displayName = import_getters.getters.credClassBody.getDisplayName(node.body);
if (!displayName)
return;
if (!displayName.value.endsWith(" API")) {
const fixed = import_utils.utils.addApiSuffix(displayName.value, {
uppercased: true
});
context.report({
messageId: "fixSuffix",
node: displayName.ast,
fix: (fixer) => fixer.replaceText(displayName.ast, `displayName = '${fixed}';`)
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_display_name_missing_oauth2_exports = {};
__export(cred_class_field_display_name_missing_oauth2_exports, {
default: () => cred_class_field_display_name_missing_oauth2_default
});
module.exports = __toCommonJS(cred_class_field_display_name_missing_oauth2_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_display_name_missing_oauth2_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`displayName` field in credential class must mention `OAuth2` if the credential is OAuth2.",
recommended: "strict"
},
schema: [],
messages: {
addOAuth2: "Add 'OAuth2' [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const extendsValue = import_getters.getters.credClassBody.getExtendsValue(
node.body,
context
);
if (!extendsValue)
return;
const displayName = import_getters.getters.credClassBody.getDisplayName(node.body);
if (!displayName)
return;
if (extendsValue.includes("oAuth2Api") && !displayName.value.endsWith("OAuth2 API")) {
context.report({
messageId: "addOAuth2",
node: displayName.ast
});
}
}
};
}
});

View File

@@ -0,0 +1,67 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_documentation_url_miscased_exports = {};
__export(cred_class_field_documentation_url_miscased_exports, {
default: () => cred_class_field_documentation_url_miscased_default
});
module.exports = __toCommonJS(cred_class_field_documentation_url_miscased_exports);
var import_camel_case = require("camel-case");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_documentation_url_miscased_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`documentationUrl` field in credential class must be camel cased. Only applicable to nodes in the main repository.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useCamelCase: "Change to camelCase [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const documentationUrl = import_getters.getters.credClassBody.getDocumentationUrl(
node.body
);
if (!documentationUrl)
return;
const camelCasedDocumentationUrl = (0, import_camel_case.camelCase)(documentationUrl.value);
if (documentationUrl.value !== camelCasedDocumentationUrl) {
context.report({
messageId: "useCamelCase",
node: documentationUrl.ast,
fix: (fixer) => fixer.replaceText(
documentationUrl.ast,
`documentationUrl = '${camelCasedDocumentationUrl}';`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,71 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_documentation_url_missing_exports = {};
__export(cred_class_field_documentation_url_missing_exports, {
default: () => cred_class_field_documentation_url_missing_default
});
module.exports = __toCommonJS(cred_class_field_documentation_url_missing_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_documentation_url_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`documentationUrl` field in credential class must be present.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addDocumentationUrl: "Add `documentationUrl` [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const { body: classBody } = node;
const documentationUrl = import_getters.getters.credClassBody.getDocumentationUrl(classBody);
if (!documentationUrl) {
const displayName = import_getters.getters.credClassBody.getDisplayName(classBody);
if (!displayName)
return;
const className = import_getters.getters.credClassBody.getName(classBody);
if (!className)
return;
const { indentation, range } = import_utils.utils.getInsertionArgs(displayName);
const fixed = className.value.replace(/(OAuth2)?Api/g, "");
context.report({
messageId: "addDocumentationUrl",
node: classBody,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}documentationUrl = '${fixed}';`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,73 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_documentation_url_not_http_url_exports = {};
__export(cred_class_field_documentation_url_not_http_url_exports, {
default: () => cred_class_field_documentation_url_not_http_url_default
});
module.exports = __toCommonJS(cred_class_field_documentation_url_not_http_url_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
const isTestRun = process.env.NODE_ENV === "test";
var cred_class_field_documentation_url_not_http_url_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`documentationUrl` field in credential class must be an HTTP URL. Only applicable to community credentials.",
recommended: "strict"
},
schema: [],
messages: {
useHttpUrl: "Use an HTTP URL, e.g. `https://example.com/docs/auth` [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
const filename = context.getFilename();
if (!import_identifiers.id.isCredentialClass(node) || !isCommunityCredential(filename)) {
return;
}
const documentationUrl = import_getters.getters.credClassBody.getDocumentationUrl(
node.body
);
if (!documentationUrl)
return;
if (!isHttpUrl(documentationUrl.value)) {
context.report({
messageId: "useHttpUrl",
node: documentationUrl.ast
});
}
}
};
}
});
function isHttpUrl(string) {
let url;
try {
url = new URL(string);
} catch (_) {
return false;
}
return url.protocol === "http:" || url.protocol === "https:";
}
const isCommunityCredential = (filename) => (!filename.includes("packages/credentials") || !filename.includes("packages\\credentials") || isTestRun) && !filename.includes("scratchpad");

View File

@@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_name_missing_oauth2_exports = {};
__export(cred_class_field_name_missing_oauth2_exports, {
default: () => cred_class_field_name_missing_oauth2_default
});
module.exports = __toCommonJS(cred_class_field_name_missing_oauth2_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_name_missing_oauth2_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`name` field in credential class must mention `OAuth2` if the credential is OAuth2.",
recommended: "strict"
},
schema: [],
messages: {
addOAuth2: "Insert 'OAuth2' [non-autofixable]"
// unpredictable input
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const { body: classBody } = node;
const extendsValue = import_getters.getters.credClassBody.getExtendsValue(
classBody,
context
);
if (!extendsValue)
return;
const name = import_getters.getters.credClassBody.getName(classBody);
if (!name)
return;
if (extendsValue.includes("oAuth2Api") && !name.value.endsWith("OAuth2Api")) {
context.report({
messageId: "addOAuth2",
node: name.ast
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_name_unsuffixed_exports = {};
__export(cred_class_field_name_unsuffixed_exports, {
default: () => cred_class_field_name_unsuffixed_default
});
module.exports = __toCommonJS(cred_class_field_name_unsuffixed_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_apiSuffixExemption = require("../ast/utils/apiSuffixExemption");
var cred_class_field_name_unsuffixed_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`name` field in credential class must be suffixed with `-Api`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixSuffix: "Suffix with '-Api' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
if ((0, import_apiSuffixExemption.isExemptedFromApiSuffix)(context.getFilename()))
return;
const name = import_getters.getters.credClassBody.getName(node.body);
if (!name)
return;
if (!name.value.endsWith("Api")) {
const fixed = import_utils.utils.addApiSuffix(name.value);
context.report({
messageId: "fixSuffix",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, `name = '${fixed}';`)
});
}
}
};
}
});

View File

@@ -0,0 +1,61 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_name_uppercase_first_char_exports = {};
__export(cred_class_field_name_uppercase_first_char_exports, {
default: () => cred_class_field_name_uppercase_first_char_default
});
module.exports = __toCommonJS(cred_class_field_name_uppercase_first_char_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_name_uppercase_first_char_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "First char in `name` in credential class must be lowercase.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
uppercaseFirstChar: "Change first char to lowercase [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const name = import_getters.getters.credClassBody.getName(node.body);
if (!name)
return;
const fixed = name.value.charAt(0).toLowerCase() + name.value.slice(1);
if (/[A-Z]/.test(name.value.charAt(0))) {
context.report({
messageId: "uppercaseFirstChar",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, `name = '${fixed}';`)
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_placeholder_url_missing_eg_exports = {};
__export(cred_class_field_placeholder_url_missing_eg_exports, {
default: () => cred_class_field_placeholder_url_missing_eg_default
});
module.exports = __toCommonJS(cred_class_field_placeholder_url_missing_eg_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_field_placeholder_url_missing_eg_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`placeholder` for a URL in credential class must be prepended with `e.g.`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
prependEg: "Prepend 'e.g.' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const placeholder = import_getters.getters.credClassBody.getPlaceholder(node.body);
if (!placeholder)
return;
if (placeholder.value.startsWith("http")) {
context.report({
messageId: "prependEg",
node: placeholder.ast,
fix: (fixer) => fixer.replaceText(
placeholder.ast,
`placeholder = 'e.g. ${placeholder.value}';`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,97 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_properties_assertion_exports = {};
__export(cred_class_field_properties_assertion_exports, {
default: () => cred_class_field_properties_assertion_default
});
module.exports = __toCommonJS(cred_class_field_properties_assertion_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var cred_class_field_properties_assertion_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "In a credential class, the field `properties` must be typed `INodeProperties` and individual properties must have no assertions.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeAssertionAndType: "Remove assertion and type field 'properties' with 'INodeProperties[]' [autofixable]",
removeAssertion: "Remove assertion [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
TSAsExpression(node) {
if (!import_utils2.utils.isCredentialFile(context.getFilename()))
return;
const assertionNodes = getAssertionNodes(node);
if (assertionNodes) {
const { insertionNode, removalNode, typingExists } = assertionNodes;
const rangeToRemove = import_utils2.utils.getRangeOfAssertion(removalNode);
if (typingExists) {
return context.report({
messageId: "removeAssertion",
node,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
context.report({
messageId: "removeAssertionAndType",
node,
fix: (fixer) => {
return [
fixer.removeRange(rangeToRemove),
fixer.insertTextAfterRange(
insertionNode.range,
": INodeProperties[]"
)
];
}
});
}
}
};
}
});
function getAssertionNodes(node) {
if (node.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeName.type === import_utils.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeName.name === "NodePropertyTypes" && node.parent?.type === import_utils.AST_NODE_TYPES.Property && node.parent.key.type === import_utils.AST_NODE_TYPES.Identifier && node.parent.key.name === "type") {
const insertionNode = node.parent?.parent?.parent?.parent;
if (!insertionNode)
return null;
if ("key" in insertionNode && "type" in insertionNode.key && // insertionNode.type === AST_NODE_TYPES.PropertyDefinition &&
// insertionNode.computed === false &&
insertionNode.key.type === import_utils.AST_NODE_TYPES.Identifier && insertionNode.key.name === "properties") {
return {
removalNode: node.typeAnnotation.typeName,
insertionNode: insertionNode.key,
typingExists: isAlreadyTyped(insertionNode)
};
}
}
return null;
}
function isAlreadyTyped(node) {
if (!node.typeAnnotation)
return false;
return node.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSTypeAnnotation && node.typeAnnotation.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSArrayType && node.typeAnnotation.typeAnnotation.elementType.type === import_utils.AST_NODE_TYPES.TSTypeReference && node.typeAnnotation.typeAnnotation.elementType.typeName.type === import_utils.AST_NODE_TYPES.Identifier && node.typeAnnotation.typeAnnotation.elementType.typeName.name === "INodeProperties";
}

View File

@@ -0,0 +1,90 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_field_type_options_password_missing_exports = {};
__export(cred_class_field_type_options_password_missing_exports, {
default: () => cred_class_field_type_options_password_missing_default
});
module.exports = __toCommonJS(cred_class_field_type_options_password_missing_exports);
var import_utils = require("../ast/utils");
var import_getters = require("../ast/getters");
var import_constants = require("../constants");
const isFalsePositive = (fieldName) => {
if (fieldName.endsWith("Url"))
return true;
return import_constants.FALSE_POSITIVE_CRED_SENSITIVE_CLASS_FIELDS.includes(fieldName);
};
const isSensitive = (fieldName) => {
if (isFalsePositive(fieldName))
return false;
return import_constants.CRED_SENSITIVE_CLASS_FIELDS.some(
(sensitiveField) => fieldName.toLowerCase().includes(sensitiveField.toLowerCase())
);
};
const sensitiveStrings = import_constants.CRED_SENSITIVE_CLASS_FIELDS.map(
(i) => `\`${i}\``
).join(",");
var cred_class_field_type_options_password_missing_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `In a sensitive string-type field, \`typeOptions.password\` must be set to \`true\` to obscure the input. A field name is sensitive if it contains the strings: ${sensitiveStrings}. See exceptions in source.`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addPasswordAutofixable: "Add `typeOptions.password` with `true` [autofixable]",
addPasswordNonAutofixable: "Add `typeOptions.password` with `true` [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
const name = import_getters.getters.nodeParam.getName(node);
if (!name || !isSensitive(name.value))
return;
const type = import_getters.getters.nodeParam.getType(node);
if (!type || type.value !== "string")
return;
const typeOptions = import_getters.getters.nodeParam.getTypeOptions(node);
if (typeOptions?.value.password === true)
return;
if (typeOptions) {
return context.report({
messageId: "addPasswordNonAutofixable",
node: typeOptions.ast
// @TODO: Autofix this case
});
}
const { indentation, range } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addPasswordAutofixable",
node: type.ast,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}typeOptions: { password: true },`
)
});
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_name_missing_oauth2_suffix_exports = {};
__export(cred_class_name_missing_oauth2_suffix_exports, {
default: () => cred_class_name_missing_oauth2_suffix_default
});
module.exports = __toCommonJS(cred_class_name_missing_oauth2_suffix_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_class_name_missing_oauth2_suffix_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "Credential class name must mention `OAuth2` if the credential is OAuth2.",
recommended: "strict"
},
schema: [],
messages: {
addOAuth2: "Insert 'OAuth2' [non-autofixable]"
// unpredictable input
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const extendsValue = import_getters.getters.credClassBody.getExtendsValue(
node.body,
context
);
if (!extendsValue)
return;
const className = import_getters.getters.getClassName(node);
if (!className)
return;
if (extendsValue.includes("oAuth2Api") && !className.value.endsWith("OAuth2Api")) {
context.report({
messageId: "addOAuth2",
node: className.ast
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_class_name_unsuffixed_exports = {};
__export(cred_class_name_unsuffixed_exports, {
default: () => cred_class_name_unsuffixed_default
});
module.exports = __toCommonJS(cred_class_name_unsuffixed_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_apiSuffixExemption = require("../ast/utils/apiSuffixExemption");
var cred_class_name_unsuffixed_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "Credential class name must be suffixed with `-Api`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixSuffix: "Suffix with '-Api' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
if ((0, import_apiSuffixExemption.isExemptedFromApiSuffix)(context.getFilename()))
return;
const className = import_getters.getters.getClassName(node);
if (!className)
return;
if (!className.value.endsWith("Api")) {
const fixed = import_utils.utils.addApiSuffix(className.value);
context.report({
messageId: "fixSuffix",
node: className.ast,
fix: (fixer) => fixer.replaceText(className.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cred_filename_against_convention_exports = {};
__export(cred_filename_against_convention_exports, {
default: () => cred_filename_against_convention_default
});
module.exports = __toCommonJS(cred_filename_against_convention_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var cred_filename_against_convention_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "Credentials filename must match credentials class name, excluding the filename suffix. Example: `TestApi.credentials.ts` matches `TestApi` in `class TestApi implements ICredentialType`.",
recommended: "strict"
},
schema: [],
messages: {
renameFile: "Rename file to {{ expected }} [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration(node) {
if (!import_identifiers.id.isCredentialClass(node))
return;
const actual = context.getFilename().replace(/\\/g, "/").split("/").pop();
if (!actual)
return;
const className = import_getters.getters.getClassName(node);
if (!className)
return;
const expected = className.value + ".credentials.ts";
if (actual !== expected) {
const topOfFile = { line: 1, column: 1 };
context.report({
messageId: "renameFile",
loc: { start: topOfFile, end: topOfFile },
data: { expected }
});
}
}
};
}
});

View File

@@ -0,0 +1,119 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_credentials_name_unsuffixed_exports = {};
__export(node_class_description_credentials_name_unsuffixed_exports, {
default: () => node_class_description_credentials_name_unsuffixed_default,
getUnsuffixedCredOptionName: () => getUnsuffixedCredOptionName
});
module.exports = __toCommonJS(node_class_description_credentials_name_unsuffixed_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_credentials_name_unsuffixed_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`name` under `credentials` in node class description must be suffixed with `-Api`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixSuffix: "Suffix with `-Api` [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
if (hasCredExemptedFromApiSuffix(context.getFilename()))
return;
const credOptions = import_getters.getters.nodeClassDescription.getCredOptions(node);
if (!credOptions)
return;
const unsuffixed = getUnsuffixedCredOptionName(credOptions);
if (unsuffixed) {
const suffixed = import_utils.utils.addApiSuffix(unsuffixed.value);
const fixed = import_utils.utils.keyValue("name", suffixed);
context.report({
messageId: "fixSuffix",
node: unsuffixed.ast,
fix: (fixer) => fixer.replaceText(unsuffixed.ast, fixed)
});
}
}
};
}
});
function getUnsuffixedCredOptionName(credOptions) {
for (const credOption of credOptions.ast.value.elements) {
for (const property of credOption.properties) {
if (import_identifiers.id.nodeClassDescription.isName(property) && typeof property.value.value === "string" && !property.value.value.endsWith("Api")) {
return {
ast: property,
value: property.value.value
};
}
}
}
return null;
}
const NODES_EXEMPTED_FROM_HAVING_CREDS_WITH_API_SUFFIX = [
"Amqp",
"Aws",
"CrateDb",
"EmailReadImap",
"EmailSend",
"FileMaker",
"Ftp",
"Git",
"Google",
"GraphQL",
"HttpRequest",
"Hubspot",
"Kafka",
"MQTT",
"Microsoft",
"MongoDb",
"MySql",
"NocoDB",
"Pipedrive",
"Postgres",
"QuestDb",
"RabbitMQ",
"Redis",
"S3",
"Snowflake",
"Ssh",
"TimescaleDb",
"Wait",
"Webhook"
];
function hasCredExemptedFromApiSuffix(filename) {
return NODES_EXEMPTED_FROM_HAVING_CREDS_WITH_API_SUFFIX.some(
(cred) => filename.includes(cred)
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getUnsuffixedCredOptionName
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_display_name_unsuffixed_trigger_node_exports = {};
__export(node_class_description_display_name_unsuffixed_trigger_node_exports, {
default: () => node_class_description_display_name_unsuffixed_trigger_node_default
});
module.exports = __toCommonJS(node_class_description_display_name_unsuffixed_trigger_node_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_display_name_unsuffixed_trigger_node_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`displayName` in node class description for trigger node must be suffixed with `-Trigger`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixInputs: "Suffix with '-Trigger' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_utils.utils.isTriggerNodeFile(context.getFilename()))
return;
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const displayName = import_getters.getters.nodeClassDescription.getDisplayName(node);
if (!displayName)
return;
const displayValue = displayName.value.replace(/\s*\(Beta\)$/, "");
if (!displayValue.endsWith("Trigger")) {
const suffixed = `${displayName.value} Trigger`;
const fixed = import_utils.utils.keyValue("displayName", suffixed);
context.report({
messageId: "fixInputs",
node: displayName.ast,
fix: (fixer) => fixer.replaceText(displayName.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,59 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_empty_string_exports = {};
__export(node_class_description_empty_string_exports, {
default: () => node_class_description_empty_string_default
});
module.exports = __toCommonJS(node_class_description_empty_string_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_empty_string_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` in node class description must be filled out.",
recommended: "strict"
},
schema: [],
messages: {
fillOutDescription: "Fill out description [non-autofixable]"
// unknowable description
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const description = import_getters.getters.nodeClassDescription.getDescription(node);
if (!description)
return;
if (description.value === "") {
context.report({
messageId: "fillOutDescription",
node: description.ast
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_icon_not_svg_exports = {};
__export(node_class_description_icon_not_svg_exports, {
default: () => node_class_description_icon_not_svg_default
});
module.exports = __toCommonJS(node_class_description_icon_not_svg_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
const iconSources = import_constants.SVG_ICON_SOURCES.join(" | ");
var node_class_description_icon_not_svg_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`icon` in node class description should be an SVG icon.",
recommended: "strict"
},
schema: [],
messages: {
useSvg: `Try to use an SVG icon. Icon sources: ${iconSources} [non-autofixable]`
// unavailable file
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const icon = import_getters.getters.nodeClassDescription.getIcon(node);
if (!icon)
return;
if (icon.value.startsWith("fa:"))
return;
if (!icon.value.endsWith(".svg")) {
context.report({
messageId: "useSvg",
node: icon.ast
});
}
}
};
}
});

View File

@@ -0,0 +1,73 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_inputs_wrong_regular_node_exports = {};
__export(node_class_description_inputs_wrong_regular_node_exports, {
default: () => node_class_description_inputs_wrong_regular_node_default
});
module.exports = __toCommonJS(node_class_description_inputs_wrong_regular_node_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_inputs_wrong_regular_node_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The number of `inputs` in node class description for regular node should be one, or two for Merge node.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixInputs: `Replace with "['main']" [autofixable]`,
fixInputsMerge: `Replace with "['main', 'main']" [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const inputs = import_getters.getters.nodeClassDescription.getInputs(node);
if (!inputs)
return;
const filename = context.getFilename();
if (!import_utils.utils.isRegularNodeFile(filename))
return;
const isMergeNode = filename.endsWith("Merge.node.ts");
const inputsTotal = inputs.value.length;
if (isMergeNode && inputsTotal !== 2) {
context.report({
messageId: "fixInputsMerge",
node: inputs.ast,
fix: (fixer) => fixer.replaceText(inputs.ast, "inputs: ['main', 'main']")
});
}
if (!isMergeNode && inputsTotal !== 1 || !isMergeNode && inputsTotal === 1 && inputs.value[0] !== "main") {
context.report({
messageId: "fixInputs",
node: inputs.ast,
fix: (fixer) => fixer.replaceText(inputs.ast, "inputs: ['main']")
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_inputs_wrong_trigger_node_exports = {};
__export(node_class_description_inputs_wrong_trigger_node_exports, {
default: () => node_class_description_inputs_wrong_trigger_node_default
});
module.exports = __toCommonJS(node_class_description_inputs_wrong_trigger_node_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_inputs_wrong_trigger_node_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The number of `inputs` in node class description for trigger node should be zero.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixInputs: "Replace with '[]' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_utils.utils.isTriggerNodeFile(context.getFilename()))
return;
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const inputs = import_getters.getters.nodeClassDescription.getInputs(node);
if (!inputs)
return;
const inputsTotal = inputs.value.length;
if (inputsTotal !== 0) {
context.report({
messageId: "fixInputs",
node: inputs.ast,
fix: (fixer) => fixer.replaceText(inputs.ast, "inputs: []")
});
}
}
};
}
});

View File

@@ -0,0 +1,93 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_missing_subtitle_exports = {};
__export(node_class_description_missing_subtitle_exports, {
default: () => node_class_description_missing_subtitle_default
});
module.exports = __toCommonJS(node_class_description_missing_subtitle_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_missing_subtitle_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`subtitle` in node class description must be present.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addSubtitle: `Add subtitle: '${import_constants.NODE_CLASS_DESCRIPTION_SUBTITLE}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const allDisplayNames = getAllDisplayNames(node);
if (!allDisplayNames)
return;
const hasNoSubtitleComponents = !allDisplayNames.every(
(dn) => ["Resource", "Operation"].includes(dn)
);
if (hasNoSubtitleComponents)
return;
if (!import_getters.getters.nodeClassDescription.getSubtitle(node)) {
const version = import_getters.getters.nodeClassDescription.getVersion(node) ?? import_getters.getters.nodeClassDescription.getDefaultVersion(node);
if (!version)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(version);
context.report({
messageId: "addSubtitle",
node,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}subtitle: '${import_constants.NODE_CLASS_DESCRIPTION_SUBTITLE}',`
)
});
}
}
};
}
});
function getAllDisplayNames(nodeParam) {
const properties = nodeParam.properties.find(
import_identifiers.id.nodeClassDescription.isProperties
);
if (!properties)
return null;
const displayNames = properties.value.elements.reduce(
(acc, element) => {
const found = element.properties?.find(import_identifiers.id.nodeParam.isDisplayName);
if (found)
acc.push(found.value.value);
return acc;
},
[]
);
if (!displayNames.length)
return null;
return displayNames;
}

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_name_miscased_exports = {};
__export(node_class_description_name_miscased_exports, {
default: () => node_class_description_name_miscased_default
});
module.exports = __toCommonJS(node_class_description_name_miscased_exports);
var import_camel_case = require("camel-case");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_name_miscased_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`name` in node class description must be camel cased.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useCamelCase: "Change to camel case [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
if (!import_utils.utils.isNodeFile(context.getFilename()))
return;
const name = import_getters.getters.nodeClassDescription.getName(node);
if (!name)
return;
const camelCased = (0, import_camel_case.camelCase)(name.value);
if (name.value !== camelCased) {
const fixed = import_utils.utils.keyValue("name", camelCased);
context.report({
messageId: "useCamelCase",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_name_unsuffixed_trigger_node_exports = {};
__export(node_class_description_name_unsuffixed_trigger_node_exports, {
default: () => node_class_description_name_unsuffixed_trigger_node_default
});
module.exports = __toCommonJS(node_class_description_name_unsuffixed_trigger_node_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_name_unsuffixed_trigger_node_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`name` in node class description for trigger node must be suffixed with `-Trigger`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixInputs: "Suffix with '-Trigger' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
if (!import_utils.utils.isTriggerNodeFile(context.getFilename()))
return;
const name = import_getters.getters.nodeClassDescription.getName(node);
if (!name)
return;
if (!name.value.endsWith("Trigger")) {
const suffixed = `${name.value}Trigger`;
const fixed = import_utils.utils.keyValue("name", suffixed);
context.report({
messageId: "fixInputs",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_non_core_color_present_exports = {};
__export(node_class_description_non_core_color_present_exports, {
default: () => node_class_description_non_core_color_present_default
});
module.exports = __toCommonJS(node_class_description_non_core_color_present_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils2 = require("@typescript-eslint/utils");
var node_class_description_non_core_color_present_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`color` in node class description is deprecated and must not be present, except for nodes whose icon is a Font Awesome icon - usually core nodes.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeColor: "Remove `color` property [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const icon = import_getters.getters.nodeClassDescription.getIcon(node);
if (icon?.value.startsWith("fa:"))
return;
const defaults = import_getters.getters.nodeClassDescription.getDefaults(node);
if (!defaults)
return;
if (defaults.ast.type === import_utils2.AST_NODE_TYPES.Property && defaults.ast.value.type === import_utils2.AST_NODE_TYPES.ObjectExpression) {
const colorProperty = defaults.ast.value.properties.find(
(property) => {
return property.type === import_utils2.AST_NODE_TYPES.Property && property.key.type === import_utils2.AST_NODE_TYPES.Identifier && property.key.name === "color";
}
);
if (!colorProperty)
return;
const rangeToRemove = import_utils.utils.getRangeToRemove({ ast: colorProperty });
context.report({
messageId: "removeColor",
node: colorProperty,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
}
};
}
});

View File

@@ -0,0 +1,83 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_class_description_outputs_wrong_exports = {};
__export(node_class_description_outputs_wrong_exports, {
default: () => node_class_description_outputs_wrong_default
});
module.exports = __toCommonJS(node_class_description_outputs_wrong_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_class_description_outputs_wrong_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The number of `outputs` in node class description for any node must be one, or two for If node, or four for Switch node.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
fixOutputs: `Replace with "['main']" [autofixable]`,
fixOutputsIf: `Replace with "['main', 'main']" [autofixable]`,
fixOutputsSwitch: `Replace with "['main', 'main', 'main', 'main']" [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const outputs = import_getters.getters.nodeClassDescription.getOutputs(node);
if (!outputs)
return;
const inputsTotal = outputs.value.length;
const name = import_getters.getters.nodeClassDescription.getName(node);
if (!name)
return;
if (name.value === "if" && inputsTotal !== 2) {
context.report({
messageId: "fixOutputsIf",
node: outputs.ast,
fix: (fixer) => fixer.replaceText(outputs.ast, "inputs: ['main', 'main']")
});
}
if (name.value === "switch" && inputsTotal !== 4) {
context.report({
messageId: "fixOutputsSwitch",
node: outputs.ast,
fix: (fixer) => fixer.replaceText(
outputs.ast,
"inputs: ['main', 'main', 'main', 'main']"
)
});
}
if (inputsTotal !== 1 || inputsTotal === 1 && outputs.value[0] !== "main") {
context.report({
messageId: "fixOutputs",
node: outputs.ast,
fix: (fixer) => fixer.replaceText(outputs.ast, "outputs: ['main']")
});
}
}
};
}
});

View File

@@ -0,0 +1,58 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_dirname_against_convention_exports = {};
__export(node_dirname_against_convention_exports, {
default: () => node_dirname_against_convention_default
});
module.exports = __toCommonJS(node_dirname_against_convention_exports);
var import_utils = require("../ast/utils");
var node_dirname_against_convention_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "Node dirname must match node filename, excluding the filename suffix. Example: `Test` node dirname matches `Test` section of `Test.node.ts` node filename.",
recommended: "strict"
},
schema: [],
messages: {
renameDir: "Rename node dir to {{ expected }} [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ClassDeclaration() {
const filepath = context.getFilename();
if (!filepath.endsWith(".node.ts"))
return;
const [filename, parentDir] = filepath.replace(/\\/g, "/").split("/").reverse().map((i) => i.replace("trigger", ""));
const expected = filename.replace(".node.ts", "");
if (!expected.toLowerCase().includes(parentDir.toLowerCase())) {
const topOfFile = { line: 1, column: 1 };
context.report({
messageId: "renameDir",
loc: { start: topOfFile, end: topOfFile },
data: { expected }
});
}
}
};
}
});

View File

@@ -0,0 +1,75 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_execute_block_double_assertion_for_items_exports = {};
__export(node_execute_block_double_assertion_for_items_exports, {
default: () => node_execute_block_double_assertion_for_items_default
});
module.exports = __toCommonJS(node_execute_block_double_assertion_for_items_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var import_getters = require("../ast/getters");
var node_execute_block_double_assertion_for_items_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "In the `execute()` method there is no need to double assert the type of `items.length`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeDoubleAssertion: "Remove double assertion [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
MethodDefinition(node) {
if (!import_utils2.utils.isNodeFile(context.getFilename()))
return;
const executeContent = import_getters.getters.nodeExecuteBlock.getExecuteContent(node);
if (!executeContent)
return;
const init = getDoublyAssertedDeclarationInit(executeContent);
if (init) {
context.report({
messageId: "removeDoubleAssertion",
node: init,
fix: (fixer) => fixer.replaceText(init, "items.length")
});
}
}
};
}
});
function getDoublyAssertedDeclarationInit(executeMethod) {
for (const node of executeMethod.body) {
if (node.type === import_utils.AST_NODE_TYPES.VariableDeclaration) {
for (const declaration of node.declarations) {
if (!declaration.init)
continue;
if (declaration.init.type === import_utils.AST_NODE_TYPES.TSAsExpression && declaration.init.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSNumberKeyword && declaration.init.expression.type === import_utils.AST_NODE_TYPES.TSAsExpression && declaration.init.expression.typeAnnotation.type === import_utils.AST_NODE_TYPES.TSUnknownKeyword && declaration.init.expression.expression.type === import_utils.AST_NODE_TYPES.MemberExpression && declaration.init.expression.expression.object.type === import_utils.AST_NODE_TYPES.Identifier && declaration.init.expression.expression.object.name === "items" && declaration.init.expression.expression.property.type === import_utils.AST_NODE_TYPES.Identifier && declaration.init.expression.expression.property.name === "length") {
return declaration.init;
}
}
}
}
return null;
}

View File

@@ -0,0 +1,132 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_execute_block_error_missing_item_index_exports = {};
__export(node_execute_block_error_missing_item_index_exports, {
default: () => node_execute_block_error_missing_item_index_default
});
module.exports = __toCommonJS(node_execute_block_error_missing_item_index_exports);
var import_utils = require("../ast/utils");
var import_getters = require("../ast/getters");
var import_utils2 = require("@typescript-eslint/utils");
var import_constants = require("../constants");
const {
nodeExecuteBlock: { getOperationConsequents, collectConsequents }
} = import_getters.getters;
var node_execute_block_error_missing_item_index_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "In the operations in the `execute()` method in a node, `NodeApiError` and `NodeOperationError` must specify `itemIndex` as the third argument.",
recommended: "strict"
},
schema: [],
messages: {
addItemIndexSameName: "Add `{ itemIndex }` as third argument [non-autofixable]",
addItemIndexDifferentName: "Add `{ itemIndex: {{ indexName }} }` as third argument [non-autofixable]",
changeThirdArgSameName: "Change third argument to `{ itemIndex }` [non-autofixable]",
changeThirdArgDifferentName: "Change third argument to `{ itemIndex: {{ indexName }} }` [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
MethodDefinition(node) {
if (!import_utils.utils.isNodeFile(context.getFilename()))
return;
const result = getOperationConsequents(node, { filter: "all" });
if (!result)
return;
const {
operationConsequents: opConsequents,
inputItemsIndexName: indexName
} = result;
const throwStatements = findThrowStatements(opConsequents);
for (const statement of throwStatements) {
if (statement.argument === null || // @ts-ignore @TODO: This does not typecheck but AST check is correct
statement.argument.type !== import_utils2.AST_NODE_TYPES.NewExpression) {
continue;
}
if (!isNodeErrorType(statement.argument))
continue;
const { arguments: errorArguments } = statement.argument;
if (errorArguments.length !== 3 && indexName === "itemIndex") {
context.report({
messageId: "addItemIndexSameName",
node: statement
});
continue;
}
if (errorArguments.length !== 3 && indexName !== "itemIndex") {
context.report({
messageId: "addItemIndexDifferentName",
node: statement,
data: { indexName }
});
continue;
}
const [thirdArg] = [...errorArguments].reverse();
if (!isItemIndexArg(thirdArg) && indexName === "itemIndex") {
context.report({
messageId: "changeThirdArgSameName",
node: statement
});
continue;
}
if (!isItemIndexArg(thirdArg) && indexName !== "itemIndex") {
context.report({
messageId: "changeThirdArgDifferentName",
node: statement,
data: { indexName }
});
continue;
}
}
}
};
}
});
function findIfStatements(consequent) {
return consequent.body.filter(
(statement) => statement.type === import_utils2.AST_NODE_TYPES.IfStatement
);
}
const isThrowStatement = (node) => node.type === import_utils2.AST_NODE_TYPES.ThrowStatement;
function findThrowStatements(operationConsequents) {
return operationConsequents.reduce(
(acc, operationConsequent) => {
const topLevelThrows = operationConsequent.body.filter(isThrowStatement);
const throwStatements = [...topLevelThrows];
const nestedIfs = findIfStatements(operationConsequent);
const nestedConsequents = nestedIfs.flatMap((s) => collectConsequents(s));
const nestedThrows = nestedConsequents.flatMap(
(c) => c.body.filter(isThrowStatement)
);
throwStatements.push(...nestedThrows);
return [...acc, ...throwStatements];
},
[]
);
}
function isNodeErrorType(newExpressionArg) {
return newExpressionArg.callee.type === import_utils2.AST_NODE_TYPES.Identifier && import_constants.N8N_NODE_ERROR_TYPES.includes(newExpressionArg.callee.name);
}
function isItemIndexArg(node) {
return node.type === import_utils2.AST_NODE_TYPES.ObjectExpression && node.properties.length === 1 && node.properties[0].type === import_utils2.AST_NODE_TYPES.Property && node.properties[0].key.type === import_utils2.AST_NODE_TYPES.Identifier && node.properties[0].key.name === "itemIndex";
}

View File

@@ -0,0 +1,79 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_execute_block_missing_continue_on_fail_exports = {};
__export(node_execute_block_missing_continue_on_fail_exports, {
default: () => node_execute_block_missing_continue_on_fail_default
});
module.exports = __toCommonJS(node_execute_block_missing_continue_on_fail_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var node_execute_block_missing_continue_on_fail_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `execute()` method in a node must implement `continueOnFail` in a try-catch block.",
recommended: "strict"
},
schema: [],
messages: {
addContinueOnFail: "Implement 'continueOnFail' [non-autofixable]"
// unknowable implementation
}
},
defaultOptions: [],
create(context) {
return {
MethodDefinition(node) {
if (!import_utils2.utils.isNodeFile(context.getFilename()))
return;
const executeForLoop = getExecuteForLoop(node);
if (!executeForLoop)
return;
const hasContinueOnFail = executeForLoop.body.some((e) => {
const tryCatch = getTryCatch(e);
if (!tryCatch)
return;
return tryCatch.body.some(isContinueOnFail);
});
if (!hasContinueOnFail) {
context.report({
messageId: "addContinueOnFail",
node
});
}
}
};
}
});
function getExecuteForLoop(node) {
if (node.key.type === import_utils.AST_NODE_TYPES.Identifier && node.key.name === "execute" && node.value.type === import_utils.AST_NODE_TYPES.FunctionExpression && node.value.body.type === import_utils.AST_NODE_TYPES.BlockStatement && node.value.body.body.length === 1 && node.value.body.body[0].type === import_utils.AST_NODE_TYPES.ForStatement && node.value.body.body[0].body.type === import_utils.AST_NODE_TYPES.BlockStatement) {
return node.value.body.body[0].body;
}
return null;
}
function getTryCatch(node) {
if (node.type === import_utils.AST_NODE_TYPES.TryStatement && node.handler !== null && node.handler.body.type === import_utils.AST_NODE_TYPES.BlockStatement) {
return node.handler.body;
}
return null;
}
function isContinueOnFail(node) {
return node.type === import_utils.AST_NODE_TYPES.IfStatement && node.test.type === import_utils.AST_NODE_TYPES.CallExpression && node.test.callee.type === import_utils.AST_NODE_TYPES.MemberExpression && node.test.callee.object.type === import_utils.AST_NODE_TYPES.ThisExpression && node.test.callee.property.type === import_utils.AST_NODE_TYPES.Identifier && node.test.callee.property.name === "continueOnFail";
}

View File

@@ -0,0 +1,58 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_execute_block_wrong_error_thrown_exports = {};
__export(node_execute_block_wrong_error_thrown_exports, {
default: () => node_execute_block_wrong_error_thrown_default
});
module.exports = __toCommonJS(node_execute_block_wrong_error_thrown_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var import_constants = require("../constants");
var node_execute_block_wrong_error_thrown_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "The `execute()` method in a node may only throw `ApplicationError`, NodeApiError`, `NodeOperationError`, or `TriggerCloseError`.",
recommended: "strict"
},
schema: [],
messages: {
useProperError: "Use `ApplicationError`, NodeApiError`, `NodeOperationError`, or `TriggerCloseError` [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
"ThrowStatement > NewExpression"(node) {
if (!import_utils2.utils.isNodeFile(context.getFilename()))
return;
if (node.callee.type !== import_utils.AST_NODE_TYPES.Identifier)
return;
const { name: errorType } = node.callee;
if (!import_constants.N8N_NODE_ERROR_TYPES.includes(errorType)) {
context.report({
messageId: "useProperError",
node
});
}
}
};
}
});

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_filename_against_convention_exports = {};
__export(node_filename_against_convention_exports, {
default: () => node_filename_against_convention_default
});
module.exports = __toCommonJS(node_filename_against_convention_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_filename_against_convention_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`name` in node class description must match the node filename without the `.node.ts` suffix. Example: If `description.name` is `Test`, then filename must be `Test.node.ts`. Version suffix in filename (e.g. `-V2`) is disregarded.",
recommended: "strict"
},
schema: [],
messages: {
renameFile: "Rename file to {{ expected }} [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeClassDescription(node))
return;
const name = import_getters.getters.nodeClassDescription.getName(node);
if (!name)
return;
const actual = import_utils.utils.getNodeFilename(context.getFilename().replace(/\\/g, "/")).replace(/V\d+\.node\.ts$/, ".node.ts");
const expected = import_utils.utils.toExpectedNodeFilename(name.value);
if (actual !== expected) {
const topOfFile = { line: 1, column: 1 };
context.report({
messageId: "renameFile",
loc: { start: topOfFile, end: topOfFile },
data: { expected }
});
}
}
};
}
});

View File

@@ -0,0 +1,81 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_array_type_assertion_exports = {};
__export(node_param_array_type_assertion_exports, {
default: () => node_param_array_type_assertion_default
});
module.exports = __toCommonJS(node_param_array_type_assertion_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var node_param_array_type_assertion_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "Array of node parameters must be typed, not type-asserted.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
typeArray: "Use ': INodeProperties[]' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
TSAsExpression(node) {
if (containsArrayOfNodeParams(node)) {
if (node.parent?.type !== import_utils.AST_NODE_TYPES.VariableDeclarator || node.parent?.id.type !== import_utils.AST_NODE_TYPES.Identifier) {
return;
}
const rangeToRemove = import_utils2.utils.getRangeToRemove({
ast: node.typeAnnotation
});
const { range } = node.parent.id;
if (!range)
return null;
const indentation = getTrailingBracketIndentation(node);
context.report({
messageId: "typeArray",
node,
fix: (fixer) => {
return [
fixer.replaceTextRange(rangeToRemove, indentation),
fixer.insertTextAfterRange(range, ": INodeProperties[]")
];
}
});
}
}
};
}
});
function containsArrayOfNodeParams(node) {
if (node.expression.type !== import_utils.AST_NODE_TYPES.ArrayExpression || node.expression.elements.length === 0) {
return false;
}
return node.expression.elements.every((element) => {
return element?.type === import_utils.AST_NODE_TYPES.ObjectExpression && import_identifiers.id.isNodeParameter(element);
});
}
function getTrailingBracketIndentation(node) {
return " ".repeat(node.expression.loc.end.column - 1);
}

View File

@@ -0,0 +1,75 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_collection_type_item_required_exports = {};
__export(node_param_collection_type_item_required_exports, {
default: () => node_param_collection_type_item_required_default
});
module.exports = __toCommonJS(node_param_collection_type_item_required_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var import_utils2 = require("@typescript-eslint/utils");
var node_param_collection_type_item_required_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `Items in collection-type node parameter must not have a \`required\` property.`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeRequired: "Remove `required: true` [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isCollectionType(node))
return;
const options = import_getters.getters.nodeParam.getCollectionOptions(node);
if (!options)
return;
if (options.value.every((param) => param.required === void 0)) {
return;
}
if (options.ast.value.type !== import_utils2.AST_NODE_TYPES.ArrayExpression)
return;
const [objectExpression] = options.ast.value.elements;
const requiredTrueProperties = objectExpression.properties.filter(
(property) => {
return property.type === import_utils2.AST_NODE_TYPES.Property && property.key.type === import_utils2.AST_NODE_TYPES.Identifier && property.key.name === "required" && property.value.type === import_utils2.AST_NODE_TYPES.Literal && property.value.value === true;
}
);
for (const property of requiredTrueProperties) {
const rangeToRemove = import_utils.utils.getRangeToRemove({ ast: property });
context.report({
messageId: "removeRequired",
node: property,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
}
};
}
});

View File

@@ -0,0 +1,71 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_collection_type_unsorted_items_exports = {};
__export(node_param_collection_type_unsorted_items_exports, {
default: () => node_param_collection_type_unsorted_items_default
});
module.exports = __toCommonJS(node_param_collection_type_unsorted_items_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_collection_type_unsorted_items_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `Items in collection-type node parameter must be alphabetized by \`name\` if ${import_constants.MIN_ITEMS_TO_ALPHABETIZE_SPELLED_OUT} or more than ${import_constants.MIN_ITEMS_TO_ALPHABETIZE_SPELLED_OUT}.`,
recommended: "strict"
},
schema: [],
messages: {
sortItems: "Alphabetize by 'name'. Order: {{ displayOrder }} [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isCollectionType(node))
return;
const options = import_getters.getters.nodeParam.getCollectionOptions(node);
if (!options)
return;
if (options.value.length < import_constants.MIN_ITEMS_TO_ALPHABETIZE)
return;
const sortedOptions = [...options.value].sort(
import_utils.utils.optionComparatorForCollection
);
if (!import_utils.utils.areIdenticallySortedOptionsForCollection(
options.value,
sortedOptions
)) {
const displayOrder = import_utils.utils.toDisplayOrderForCollection(sortedOptions);
context.report({
messageId: "sortItems",
node: options.ast,
data: { displayOrder }
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_color_type_unused_exports = {};
__export(node_param_color_type_unused_exports, {
default: () => node_param_color_type_unused_default
});
module.exports = __toCommonJS(node_param_color_type_unused_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_color_type_unused_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`string`-type color-related node parameter must be `color`-type.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useColorParam: "Use 'color' for 'type' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
const name = import_getters.getters.nodeParam.getName(node);
if (!name)
return;
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
if (/colo(u?)r/i.test(name.value) && type.value === "string") {
context.report({
messageId: "useColorParam",
node: type.ast,
fix: (fixer) => fixer.replaceText(type.ast, "type: 'color'")
});
}
}
};
}
});

View File

@@ -0,0 +1,94 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_missing_exports = {};
__export(node_param_default_missing_exports, {
default: () => node_param_default_missing_default
});
module.exports = __toCommonJS(node_param_default_missing_exports);
var import_utils = require("@typescript-eslint/utils");
var import_utils2 = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_missing_default = import_utils2.utils.createRule({
name: import_utils2.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` must be present in a node parameter, except in node parameters under `modes`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addDefault: "Add a default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node, { skipKeys: ["default"] }))
return;
if (node.parent?.parent) {
if (node.parent.parent.type === import_utils.AST_NODE_TYPES.Property && node.parent.parent.key.type === import_utils.AST_NODE_TYPES.Identifier && node.parent.parent.key.name === "modes") {
return;
}
}
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const fixValues = {
string: "",
number: 0,
boolean: false,
options: getDefaultForOptionsTypeParam(node),
multiOptions: [],
collection: {},
fixedCollection: {}
};
const _default = import_getters.getters.nodeParam.getDefault(node);
if (_default?.isUnparseable)
return;
if (!_default) {
const { range, indentation } = import_utils2.utils.getInsertionArgs(type);
context.report({
messageId: "addDefault",
node,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}default: '${fixValues[type.value]}',`
)
});
}
}
};
}
});
function getDefaultForOptionsTypeParam(node) {
const zerothOption = getZerothOption(node);
if (!zerothOption)
return "";
return zerothOption.value;
}
function getZerothOption(nodeParamArg) {
if (!import_identifiers.id.nodeParam.isOptionsType(nodeParamArg))
return null;
return import_getters.getters.nodeParam.getOptions(nodeParamArg)?.value[0] ?? null;
}

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_boolean_exports = {};
__export(node_param_default_wrong_for_boolean_exports, {
default: () => node_param_default_wrong_for_boolean_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_boolean_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_boolean_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for boolean-type node parameter must be a boolean.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setBooleanDefault: "Set a boolean default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isBooleanType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (typeof _default.value !== "boolean") {
context.report({
messageId: "setBooleanDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: false")
});
}
}
};
}
});

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_collection_exports = {};
__export(node_param_default_wrong_for_collection_exports, {
default: () => node_param_default_wrong_for_collection_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_collection_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_collection_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for collection-type node parameter must be an object.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setObjectDefault: "Set an object default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isCollectionType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (!Array.isArray(_default.value) && _default.value !== null && typeof _default.value !== "object") {
context.report({
messageId: "setObjectDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: {}")
});
}
}
};
}
});

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_fixed_collection_exports = {};
__export(node_param_default_wrong_for_fixed_collection_exports, {
default: () => node_param_default_wrong_for_fixed_collection_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_fixed_collection_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_fixed_collection_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for fixed-collection-type node parameter must be an object.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setObjectDefault: "Set an object default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isFixedCollectionType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (!Array.isArray(_default.value) && _default.value !== null && typeof _default.value !== "object") {
context.report({
messageId: "setObjectDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: {}")
});
}
}
};
}
});

View File

@@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_limit_exports = {};
__export(node_param_default_wrong_for_limit_exports, {
default: () => node_param_default_wrong_for_limit_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_limit_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_limit_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`default\` for a Limit node parameter must be \`${import_constants.LIMIT_NODE_PARAMETER.DEFAULT_VALUE}\`.`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setLimitDefault: `Set ${import_constants.LIMIT_NODE_PARAMETER.DEFAULT_VALUE} as default [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isLimit(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (_default.value !== import_constants.LIMIT_NODE_PARAMETER.DEFAULT_VALUE) {
context.report({
messageId: "setLimitDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(
_default.ast,
`default: ${import_constants.LIMIT_NODE_PARAMETER.DEFAULT_VALUE}`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_multi_options_exports = {};
__export(node_param_default_wrong_for_multi_options_exports, {
default: () => node_param_default_wrong_for_multi_options_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_multi_options_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_multi_options_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for a multi-options-type node parameter must be an array.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setArrayDefault: "Set an array as default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isMultiOptionsType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (!Array.isArray(_default.value)) {
context.report({
messageId: "setArrayDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, `default: []`)
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_number_exports = {};
__export(node_param_default_wrong_for_number_exports, {
default: () => node_param_default_wrong_for_number_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_number_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_number_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for a number-type node parameter must be a number, except for a number-type ID parameter.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setNumberDefault: "Set a number default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isNumericType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (!Boolean(_default.value))
return;
if (typeof _default.value !== "number") {
context.report({
messageId: "setNumberDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: 0")
});
}
}
};
}
});

View File

@@ -0,0 +1,89 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_options_exports = {};
__export(node_param_default_wrong_for_options_exports, {
default: () => node_param_default_wrong_for_options_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_options_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_options_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for an options-type node parameter must be one of the options.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
chooseOption: "Set one of {{ eligibleOptions }} as default [autofixable]",
setEmptyString: "Set an empty string as default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isOptionsType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
const options = import_getters.getters.nodeParam.getOptions(node);
if (!options && _default.value !== "") {
context.report({
messageId: "setEmptyString",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: ''")
});
}
if (!options)
return;
if (options.hasPropertyPointingToIdentifier || // e.g. `value: myVar`
options.hasPropertyPointingToMemberExpression) {
return;
}
const eligibleOptions = options.value.reduce(
// @ts-ignore @TODO
(acc, option) => {
return acc.push(option.value), acc;
},
[]
);
if (!eligibleOptions.includes(_default.value)) {
const zerothOption = eligibleOptions[0];
const fixed = `default: ${typeof zerothOption === "string" ? `'${zerothOption}'` : zerothOption}`;
context.report({
messageId: "chooseOption",
data: {
eligibleOptions: eligibleOptions.join(" or ")
},
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_simplify_exports = {};
__export(node_param_default_wrong_for_simplify_exports, {
default: () => node_param_default_wrong_for_simplify_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_simplify_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_simplify_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for a Simplify node parameter must be `true`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setTrueDefault: "Set 'true' as default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isSimplify(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (_default.value === false) {
context.report({
messageId: "setTrueDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: true")
});
}
}
};
}
});

View File

@@ -0,0 +1,68 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_default_wrong_for_string_exports = {};
__export(node_param_default_wrong_for_string_exports, {
default: () => node_param_default_wrong_for_string_default
});
module.exports = __toCommonJS(node_param_default_wrong_for_string_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_default_wrong_for_string_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`default` for a string-type node parameter must be a string, unless `typeOptions.multipleValues` is set to `true`.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setStringDefault: "Set a string default [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isStringType(node))
return;
const _default = import_getters.getters.nodeParam.getDefault(node);
if (!_default)
return;
if (_default?.isUnparseable)
return;
const typeOptions = import_getters.getters.nodeParam.getTypeOptions(node);
if (typeOptions?.value.multipleValues && Array.isArray(_default.value)) {
return;
}
if (typeof _default.value !== "string") {
context.report({
messageId: "setStringDefault",
node: _default.ast,
fix: (fixer) => fixer.replaceText(_default.ast, "default: ''")
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_boolean_without_whether_exports = {};
__export(node_param_description_boolean_without_whether_exports, {
default: () => node_param_description_boolean_without_whether_default
});
module.exports = __toCommonJS(node_param_description_boolean_without_whether_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_boolean_without_whether_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` in a boolean node parameter must start with `Whether`.",
recommended: "strict"
},
schema: [],
messages: {
useWhether: "Start with 'Whether' [non-autofixable]"
// unpredictable input, unknowable description
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isBooleanType(node))
return;
if (import_identifiers.id.nodeParam.isSimplify(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (!description.value.startsWith("Whether")) {
context.report({
messageId: "useWhether",
node: description.ast
});
}
}
};
}
});

View File

@@ -0,0 +1,68 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_comma_separated_hyphen_exports = {};
__export(node_param_description_comma_separated_hyphen_exports, {
default: () => node_param_description_comma_separated_hyphen_default
});
module.exports = __toCommonJS(node_param_description_comma_separated_hyphen_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_comma_separated_hyphen_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `The string \`comma-separated\` in \`description\` must be hyphenated. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
hyphenate: "Hyphenate [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (description.value.toLowerCase().includes("omma separated")) {
const hyphenated = description.value.replace(
/omma separated/g,
"omma-separated"
);
const fixed = import_utils.utils.keyValue("description", hyphenated, {
backtickedValue: import_utils.utils.isMultiline(description)
});
context.report({
messageId: "hyphenate",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_empty_string_exports = {};
__export(node_param_description_empty_string_exports, {
default: () => node_param_description_empty_string_default
});
module.exports = __toCommonJS(node_param_description_empty_string_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_empty_string_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter or in option in options-type and multi-options-type param must be filled out or removed. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
schema: [],
fixable: "code",
messages: {
fillOutOrRemoveDescription: "Fill out or remove description [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
if (import_getters.getters.nodeParam.getLoadOptionsMethod(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (description.value === "") {
const rangeToRemove = import_utils.utils.getRangeToRemove(description);
context.report({
messageId: "fillOutOrRemoveDescription",
node: description.ast,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
}
};
}
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_excess_final_period_exports = {};
__export(node_param_description_excess_final_period_exports, {
default: () => node_param_description_excess_final_period_default
});
module.exports = __toCommonJS(node_param_description_excess_final_period_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_excess_final_period_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must end without a final period if a single-sentence description. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
excessFinalPeriod: "Remove final period [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (/\s{2,}/.test(description.value))
return;
if (import_identifiers.id.isWeakDescription(description))
return;
const { value } = description;
const egLess = value.replace("e.g.", "");
if (egLess.split(". ").length === 1 && egLess.endsWith(".")) {
const withoutExcess = value.slice(0, value.length - 1);
const fixed = import_utils.utils.keyValue("description", withoutExcess);
context.report({
messageId: "excessFinalPeriod",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_excess_inner_whitespace_exports = {};
__export(node_param_description_excess_inner_whitespace_exports, {
default: () => node_param_description_excess_inner_whitespace_default
});
module.exports = __toCommonJS(node_param_description_excess_inner_whitespace_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_excess_inner_whitespace_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must not contain excess inner whitespace. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeInnerWhitespace: "Remove excess inner whitespace [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const isMultiline = import_utils.utils.isMultiline(description);
if (isMultiline && /</.test(description.value))
return;
if (/\s{2,}/.test(description.value)) {
const withoutExcess = description.value.replace(/\s{2,}/g, " ");
const fixed = import_utils.utils.keyValue("description", withoutExcess);
context.report({
messageId: "removeInnerWhitespace",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_identical_to_display_name_exports = {};
__export(node_param_description_identical_to_display_name_exports, {
default: () => node_param_description_identical_to_display_name_default
});
module.exports = __toCommonJS(node_param_description_identical_to_display_name_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_identical_to_display_name_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` in node parameter must not be identical to `displayName`.",
recommended: "strict"
},
schema: [],
fixable: "code",
messages: {
removeDescription: "Remove omittable description [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const displayName = import_getters.getters.nodeParam.getDisplayName(node);
if (!displayName)
return;
const triviaLess = description.value.replace(/^The\s/g, "").replace(/\.$/, "");
if (triviaLess.toLowerCase() === displayName.value.toLowerCase()) {
const rangeToRemove = import_utils.utils.getRangeToRemove(description);
context.report({
messageId: "removeDescription",
node: description.ast,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
}
};
}
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_line_break_html_tag_exports = {};
__export(node_param_description_line_break_html_tag_exports, {
default: () => node_param_description_line_break_html_tag_default
});
module.exports = __toCommonJS(node_param_description_line_break_html_tag_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_line_break_html_tag_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must not contain an HTML line break. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeTag: "Remove line break [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
if (import_identifiers.id.isReturnValue(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (description.value.includes("PRIVATE KEY"))
return;
if (description.value.includes("<br><br>"))
return;
if (import_constants.LINE_BREAK_HTML_TAG_REGEX.test(description.value)) {
const clean = description.value.replace(new RegExp(import_constants.LINE_BREAK_HTML_TAG_REGEX, "g"), "").replace(/\s{2,}/, " ");
const fixed = import_utils.utils.keyValue("description", clean);
context.report({
messageId: "removeTag",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,67 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_lowercase_first_char_exports = {};
__export(node_param_description_lowercase_first_char_exports, {
default: () => node_param_description_lowercase_first_char_default
});
module.exports = __toCommonJS(node_param_description_lowercase_first_char_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_lowercase_first_char_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `First char in \`description\` in node parameter must be uppercase. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
uppercaseFirstChar: "Change first char to uppercase [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
if (import_identifiers.id.isReturnValue(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const { value } = description;
const firstChar = value.charAt(0);
if (/[a-z]/.test(firstChar)) {
const correctlyCased = firstChar.toUpperCase() + value.slice(1);
const fixed = import_utils.utils.keyValue("description", correctlyCased);
context.report({
messageId: "uppercaseFirstChar",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_miscased_id_exports = {};
__export(node_param_description_miscased_id_exports, {
default: () => node_param_description_miscased_id_default
});
module.exports = __toCommonJS(node_param_description_miscased_id_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_miscased_id_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`ID\` in \`description\` in node parameter must be fully uppercased. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
uppercaseId: "Use 'ID' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (import_constants.MISCASED_ID_REGEX.test(description.value)) {
const correctlyCased = description.value.replace(/\bid\b/i, "ID").replace(/\bids\b/i, "IDs");
const fixed = import_utils.utils.keyValue("description", correctlyCased);
context.report({
messageId: "uppercaseId",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_miscased_json_exports = {};
__export(node_param_description_miscased_json_exports, {
default: () => node_param_description_miscased_json_default
});
module.exports = __toCommonJS(node_param_description_miscased_json_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_miscased_json_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`JSON\` in \`description\` in node parameter must be fully uppercased. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
uppercaseJson: "Use 'JSON' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (import_constants.MISCASED_JSON_REGEX.test(description.value)) {
const correctlyCased = description.value.replace(
/\bjson\b/gi,
"JSON"
);
const fixed = import_utils.utils.keyValue("description", correctlyCased);
context.report({
messageId: "uppercaseJson",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,63 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_miscased_url_exports = {};
__export(node_param_description_miscased_url_exports, {
default: () => node_param_description_miscased_url_default
});
module.exports = __toCommonJS(node_param_description_miscased_url_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_miscased_url_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`URL\` in \`description\` in node parameter must be fully uppercased. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
uppercaseUrl: "Use 'URL' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (import_constants.MISCASED_URL_REGEX.test(description.value)) {
const correctlyCased = description.value.replace(/\burl\b/gi, "URL").replace(/\burls\b/gi, "URLs");
const fixed = import_utils.utils.keyValue("description", correctlyCased);
context.report({
messageId: "uppercaseUrl",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,68 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_final_period_exports = {};
__export(node_param_description_missing_final_period_exports, {
default: () => node_param_description_missing_final_period_default
});
module.exports = __toCommonJS(node_param_description_missing_final_period_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_final_period_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must end with a final period if a multiple-sentence description, unless ending with \`</code>\`. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
missingFinalPeriod: "Add final period [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (description.value !== description.value.trim())
return;
if (/\s{2,}/.test(description.value))
return;
const egLess = description.value.replace("e.g.", "");
if (egLess.split(". ").length === 2 && !egLess.endsWith(".") && !isAllowedNoFinalPeriod(egLess)) {
const fixed = import_utils.utils.keyValue("description", description.value + ".");
context.report({
messageId: "missingFinalPeriod",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});
const isAllowedNoFinalPeriod = (value) => value.endsWith("---") || value.endsWith("</code>");

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_for_ignore_ssl_issues_exports = {};
__export(node_param_description_missing_for_ignore_ssl_issues_exports, {
default: () => node_param_description_missing_for_ignore_ssl_issues_default
});
module.exports = __toCommonJS(node_param_description_missing_for_ignore_ssl_issues_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_for_ignore_ssl_issues_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` for Ignore SSL node parameter must be present.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addIgnoreSslIssuesDescription: `Add description: '${import_constants.IGNORE_SSL_ISSUES_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isIgnoreSslIssues(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description) {
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addIgnoreSslIssuesDescription",
node,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}description: '${import_constants.IGNORE_SSL_ISSUES_NODE_PARAMETER.DESCRIPTION}',`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_for_return_all_exports = {};
__export(node_param_description_missing_for_return_all_exports, {
default: () => node_param_description_missing_for_return_all_default
});
module.exports = __toCommonJS(node_param_description_missing_for_return_all_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_for_return_all_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` for Return All node parameter must be present.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addReturnAllDescription: `Add description: '${import_constants.RETURN_ALL_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isReturnAll(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description) {
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addReturnAllDescription",
node,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}description: '${import_constants.RETURN_ALL_NODE_PARAMETER.DESCRIPTION}',`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_for_simplify_exports = {};
__export(node_param_description_missing_for_simplify_exports, {
default: () => node_param_description_missing_for_simplify_default
});
module.exports = __toCommonJS(node_param_description_missing_for_simplify_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_for_simplify_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` for Simplify node parameter must be present.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addSimplifyDescription: `Add description: '${import_constants.SIMPLIFY_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isSimplify(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description) {
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addSimplifyDescription",
node,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}description: '${import_constants.SIMPLIFY_NODE_PARAMETER.DESCRIPTION}',`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_from_dynamic_multi_options_exports = {};
__export(node_param_description_missing_from_dynamic_multi_options_exports, {
default: () => node_param_description_missing_from_dynamic_multi_options_default
});
module.exports = __toCommonJS(node_param_description_missing_from_dynamic_multi_options_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_from_dynamic_multi_options_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` in dynamic-multi-options-type node parameter must be present.",
recommended: "strict"
},
schema: [],
fixable: "code",
messages: {
addStandardDescription: `Add description: '${import_constants.DYNAMIC_MULTI_OPTIONS_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isMultiOptionsType(node))
return;
const loadOptionsMethod = import_getters.getters.nodeParam.getLoadOptionsMethod(node);
if (!loadOptionsMethod)
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description) {
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addStandardDescription",
node: type.ast,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}description: '${import_constants.DYNAMIC_MULTI_OPTIONS_NODE_PARAMETER.DESCRIPTION}',`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_from_dynamic_options_exports = {};
__export(node_param_description_missing_from_dynamic_options_exports, {
default: () => node_param_description_missing_from_dynamic_options_default
});
module.exports = __toCommonJS(node_param_description_missing_from_dynamic_options_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_from_dynamic_options_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` in dynamic-options-type node parameter must be present.",
recommended: "strict"
},
schema: [],
fixable: "code",
messages: {
addStandardDescription: `Add description: '${import_constants.DYNAMIC_OPTIONS_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isOptionsType(node))
return;
const loadOptionsMethod = import_getters.getters.nodeParam.getLoadOptionsMethod(node);
if (!loadOptionsMethod)
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description) {
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addStandardDescription",
node: type.ast,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}description: '${import_constants.DYNAMIC_OPTIONS_NODE_PARAMETER.DESCRIPTION}',`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_missing_from_limit_exports = {};
__export(node_param_description_missing_from_limit_exports, {
default: () => node_param_description_missing_from_limit_default
});
module.exports = __toCommonJS(node_param_description_missing_from_limit_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_missing_from_limit_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "`description` in Limit node parameter must be present.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addDescription: `Add description: '${import_constants.LIMIT_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isLimit(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description) {
const type = import_getters.getters.nodeParam.getType(node);
if (!type)
return;
const { range, indentation } = import_utils.utils.getInsertionArgs(type);
context.report({
messageId: "addDescription",
node,
fix: (fixer) => fixer.insertTextAfterRange(
range,
`
${indentation}description: '${import_constants.LIMIT_NODE_PARAMETER.DESCRIPTION}',`
)
});
}
}
};
}
});

View File

@@ -0,0 +1,69 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_unencoded_angle_brackets_exports = {};
__export(node_param_description_unencoded_angle_brackets_exports, {
default: () => node_param_description_unencoded_angle_brackets_default
});
module.exports = __toCommonJS(node_param_description_unencoded_angle_brackets_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_unencoded_angle_brackets_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must encode angle brackets for them to render. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
encodeAngleBrackets: "Encode angle brackets with '&lt;' and '&gt;' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (!/(<.*>)/.test(description.value))
return;
if (description.value.includes("PRIVATE KEY"))
return;
if (!import_constants.VALID_HTML_TAG_REGEX.test(description.value)) {
const encoded = description.value.replace(/</g, "&lt;").replace(/>/g, "&gt;");
const fixed = import_utils.utils.keyValue("description", encoded, {
backtickedValue: import_utils.utils.isMultiline(description)
});
context.report({
messageId: "encodeAngleBrackets",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,64 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_unneeded_backticks_exports = {};
__export(node_param_description_unneeded_backticks_exports, {
default: () => node_param_description_unneeded_backticks_default
});
module.exports = __toCommonJS(node_param_description_unneeded_backticks_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_unneeded_backticks_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must not use unneeded backticks. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useSingleQuotes: "Use quotes instead [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (import_utils.utils.isMultiline(description))
return;
if (description.hasUnneededBackticks) {
const fixed = import_utils.utils.keyValue("description", description.value);
context.report({
messageId: "useSingleQuotes",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_untrimmed_exports = {};
__export(node_param_description_untrimmed_exports, {
default: () => node_param_description_untrimmed_default
});
module.exports = __toCommonJS(node_param_description_untrimmed_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_untrimmed_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must be trimmed. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
trimWhitespace: "Trim whitespace [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const trimmed = description.value.trim();
if (description.value !== trimmed) {
const fixed = import_utils.utils.keyValue("description", trimmed, {
backtickedValue: import_utils.utils.isMultiline(description)
});
context.report({
messageId: "trimWhitespace",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,66 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_url_missing_protocol_exports = {};
__export(node_param_description_url_missing_protocol_exports, {
default: () => node_param_description_url_missing_protocol_default
});
module.exports = __toCommonJS(node_param_description_url_missing_protocol_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_url_missing_protocol_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must include protocol e.g. \`https://\` when containing a URL. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
addProtocol: "Prepend 'https://' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (/<a href=/.test(description.value) && !/href=["']https:\/\//.test(description.value)) {
const withProtocol = description.value.replace(
/href=(['"])/g,
"href=$1https://"
);
const fixed = import_utils.utils.keyValue("description", withProtocol);
context.report({
messageId: "addProtocol",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,62 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_weak_exports = {};
__export(node_param_description_weak_exports, {
default: () => node_param_description_weak_default
});
module.exports = __toCommonJS(node_param_description_weak_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_weak_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in node parameter must be either useful or omitted. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_DESCRIPTION_IN_OPTION}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeWeakDescription: "Remove omittable description [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node) && !import_identifiers.id.isOption(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
if (import_identifiers.id.isWeakDescription(description)) {
const rangeToRemove = import_utils.utils.getRangeToRemove(description);
context.report({
messageId: "removeWeakDescription",
node: description.ast,
fix: (fixer) => fixer.removeRange(rangeToRemove)
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_dynamic_multi_options_exports = {};
__export(node_param_description_wrong_for_dynamic_multi_options_exports, {
default: () => node_param_description_wrong_for_dynamic_multi_options_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_dynamic_multi_options_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_dynamic_multi_options_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in dynamic-multi-options-type node parameter must be \`${import_constants.DYNAMIC_MULTI_OPTIONS_NODE_PARAMETER.DESCRIPTION}\``,
recommended: "strict"
},
schema: [],
fixable: "code",
messages: {
useStandardDescription: `Use '${import_constants.DYNAMIC_MULTI_OPTIONS_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isMultiOptionsType(node))
return;
const loadOptionsMethod = import_getters.getters.nodeParam.getLoadOptionsMethod(node);
if (!loadOptionsMethod)
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const expected = import_constants.DYNAMIC_MULTI_OPTIONS_NODE_PARAMETER.DESCRIPTION;
if (!description.value.endsWith(expected) && !description.value.endsWith(expected + ".")) {
const sentences = description.value.split(". ").map((s) => s.endsWith(".") ? s.slice(0, -1) : s);
const fixed = import_utils.utils.keyValue(
"description",
sentences.length === 1 && sentences[0] === "" ? expected : [...sentences, expected].join(". ") + "."
);
context.report({
messageId: "useStandardDescription",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,72 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_dynamic_options_exports = {};
__export(node_param_description_wrong_for_dynamic_options_exports, {
default: () => node_param_description_wrong_for_dynamic_options_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_dynamic_options_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_dynamic_options_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` in dynamic-options-type node parameter must be \`${import_constants.DYNAMIC_OPTIONS_NODE_PARAMETER.DESCRIPTION}\``,
recommended: "strict"
},
schema: [],
fixable: "code",
messages: {
useStandardDescription: `Use '${import_constants.DYNAMIC_OPTIONS_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isOptionsType(node))
return;
const loadOptionsMethod = import_getters.getters.nodeParam.getLoadOptionsMethod(node);
if (!loadOptionsMethod)
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const expected = import_constants.DYNAMIC_OPTIONS_NODE_PARAMETER.DESCRIPTION;
if (!description.value.endsWith(expected) && !description.value.endsWith(expected + ".")) {
const sentences = description.value.split(". ").map((s) => s.endsWith(".") ? s.slice(0, -1) : s);
const fixed = import_utils.utils.keyValue(
"description",
sentences.length === 1 && sentences[0] === "" ? expected : [...sentences, expected].join(". ") + "."
);
context.report({
messageId: "useStandardDescription",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_ignore_ssl_issues_exports = {};
__export(node_param_description_wrong_for_ignore_ssl_issues_exports, {
default: () => node_param_description_wrong_for_ignore_ssl_issues_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_ignore_ssl_issues_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_ignore_ssl_issues_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` for Ignore SSL node parameter must be \`${import_constants.IGNORE_SSL_ISSUES_NODE_PARAMETER.DESCRIPTION}\``,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useIgnoreSslDescription: `Replace with '${import_constants.IGNORE_SSL_ISSUES_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isIgnoreSslIssues(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const expected = import_constants.IGNORE_SSL_ISSUES_NODE_PARAMETER.DESCRIPTION;
if (description.value !== expected) {
const fixed = import_utils.utils.keyValue("description", expected);
context.report({
messageId: "useIgnoreSslDescription",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_limit_exports = {};
__export(node_param_description_wrong_for_limit_exports, {
default: () => node_param_description_wrong_for_limit_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_limit_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_limit_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` for Limit node parameter must be \`${import_constants.LIMIT_NODE_PARAMETER.DESCRIPTION}\``,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useLimit: `Replace with '${import_constants.LIMIT_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isLimit(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const expected = import_constants.LIMIT_NODE_PARAMETER.DESCRIPTION;
if (description.value !== expected) {
const fixed = import_utils.utils.keyValue("description", expected);
context.report({
messageId: "useLimit",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_return_all_exports = {};
__export(node_param_description_wrong_for_return_all_exports, {
default: () => node_param_description_wrong_for_return_all_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_return_all_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_return_all_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` for Return All node parameter must be \`${import_constants.RETURN_ALL_NODE_PARAMETER.DESCRIPTION}\``,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useReturnAll: `Replace with '${import_constants.RETURN_ALL_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isReturnAll(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const expected = import_constants.RETURN_ALL_NODE_PARAMETER.DESCRIPTION;
if (description.value !== expected) {
const fixed = import_utils.utils.keyValue("description", expected);
context.report({
messageId: "useReturnAll",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,65 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_simplify_exports = {};
__export(node_param_description_wrong_for_simplify_exports, {
default: () => node_param_description_wrong_for_simplify_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_simplify_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_simplify_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` for Simplify node parameter must be \`${import_constants.SIMPLIFY_NODE_PARAMETER.DESCRIPTION}\``,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useSimplify: `Replace with '${import_constants.SIMPLIFY_NODE_PARAMETER.DESCRIPTION}' [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
if (!import_identifiers.id.nodeParam.isSimplify(node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const expected = import_constants.SIMPLIFY_NODE_PARAMETER.DESCRIPTION;
if (description.value !== expected) {
const fixed = import_utils.utils.keyValue("description", expected);
context.report({
messageId: "useSimplify",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,67 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_description_wrong_for_upsert_exports = {};
__export(node_param_description_wrong_for_upsert_exports, {
default: () => node_param_description_wrong_for_upsert_default
});
module.exports = __toCommonJS(node_param_description_wrong_for_upsert_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_description_wrong_for_upsert_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`description\` for Upsert node parameter must be \`${import_constants.UPSERT_NODE_PARAMETER.DESCRIPTION}\`. The resource name e.g. \`'contact'\` is also allowed instead of \`'record'\`.`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useUpsertDescription: `Replace with '${import_constants.UPSERT_NODE_PARAMETER.DESCRIPTION}'. [autofixable]`
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isOption(node))
return;
if (!import_identifiers.id.hasValue("upsert", node))
return;
const description = import_getters.getters.nodeParam.getDescription(node);
if (!description)
return;
const { value } = description;
const expected = import_constants.UPSERT_NODE_PARAMETER.DESCRIPTION;
const [expectedStart, expectedEnd] = expected.split("record");
if (value !== expected && (!value.startsWith(expectedStart) || !value.endsWith(expectedEnd))) {
const fixed = import_utils.utils.keyValue("description", expected);
context.report({
messageId: "useUpsertDescription",
node: description.ast,
fix: (fixer) => fixer.replaceText(description.ast, fixed)
});
}
}
};
}
});

View File

@@ -0,0 +1,81 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_display_name_excess_inner_whitespace_exports = {};
__export(node_param_display_name_excess_inner_whitespace_exports, {
default: () => node_param_display_name_excess_inner_whitespace_default
});
module.exports = __toCommonJS(node_param_display_name_excess_inner_whitespace_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_display_name_excess_inner_whitespace_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`displayName\` in node parameter or in fixed collection section must not contain excess inner whitespace. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_NAME}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
removeInnerWhitespace: "Remove excess inner whitespace [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
const isNodeParameter = import_identifiers.id.isNodeParameter(node);
const isFixedCollectionSection = import_identifiers.id.isFixedCollectionSection(node);
const isOption = import_identifiers.id.isOption(node);
if (!isNodeParameter && !isFixedCollectionSection && !isOption)
return;
if (isNodeParameter || isFixedCollectionSection) {
const displayName = import_getters.getters.nodeParam.getDisplayName(node);
if (!displayName)
return;
if (/\s{2,}/.test(displayName.value)) {
const withoutExcess = displayName.value.replace(/\s{2,}/g, " ");
const fixed = import_utils.utils.keyValue("displayName", withoutExcess);
context.report({
messageId: "removeInnerWhitespace",
node: displayName.ast,
fix: (fixer) => fixer.replaceText(displayName.ast, fixed)
});
}
} else if (isOption) {
const name = import_getters.getters.nodeParam.getName(node);
if (!name)
return;
if (/\s{2,}/.test(name.value)) {
const withoutExcess = name.value.replace(/\s{2,}/g, " ");
const fixed = import_utils.utils.keyValue("name", withoutExcess);
context.report({
messageId: "removeInnerWhitespace",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, fixed)
});
}
}
}
};
}
});

View File

@@ -0,0 +1,82 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_display_name_miscased_id_exports = {};
__export(node_param_display_name_miscased_id_exports, {
default: () => node_param_display_name_miscased_id_default
});
module.exports = __toCommonJS(node_param_display_name_miscased_id_exports);
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_display_name_miscased_id_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`ID\` in \`displayName\` in node parameter must be fully uppercased. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_NAME}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
uppercaseId: "Use 'ID' [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
const isNodeParameter = import_identifiers.id.isNodeParameter(node);
const isOption = import_identifiers.id.isOption(node);
if (!isNodeParameter && !isOption)
return;
if (isNodeParameter) {
const displayName = import_getters.getters.nodeParam.getDisplayName(node);
if (!displayName)
return;
if (import_constants.MISCASED_ID_REGEX.test(displayName.value)) {
const correctlyCased = displayName.value.replace(/\bid\b/i, "ID").replace(/\bids\b/i, "IDs");
const fixed = import_utils.utils.keyValue("displayName", correctlyCased);
context.report({
messageId: "uppercaseId",
node: displayName.ast,
fix: (fixer) => fixer.replaceText(displayName.ast, fixed)
});
}
} else if (isOption) {
const name = import_getters.getters.nodeParam.getName(node);
if (!name)
return;
if (import_constants.MISCASED_ID_REGEX.test(name.value)) {
if (name.value.startsWith("="))
return;
const correctlyCased = name.value.replace(/\bid\b/i, "ID").replace(/\bids\b/i, "IDs");
const fixed = import_utils.utils.keyValue("name", correctlyCased);
context.report({
messageId: "uppercaseId",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, fixed)
});
}
}
}
};
}
});

View File

@@ -0,0 +1,98 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_display_name_miscased_exports = {};
__export(node_param_display_name_miscased_exports, {
default: () => node_param_display_name_miscased_default
});
module.exports = __toCommonJS(node_param_display_name_miscased_exports);
var import_title_case = require("title-case");
var import_constants = require("../constants");
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_display_name_miscased_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: `\`displayName\` in node parameter or in fixed collection section must title cased. ${import_constants.DOCUMENTATION.APPLICABLE_BY_EXTENSION_TO_NAME}`,
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
useTitleCase: "Change to title case [autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
const filename = import_utils.utils.getNodeFilename(context.getFilename());
if (filename === "GenericFunctions.ts")
return;
if (import_identifiers.id.isArgument(node))
return;
const isNodeParameter = import_identifiers.id.isNodeParameter(node);
const isFixedCollectionSection = import_identifiers.id.isFixedCollectionSection(node);
const isOption = import_identifiers.id.isOption(node);
if (!isNodeParameter && !isFixedCollectionSection && !isOption)
return;
if (isNodeParameter || isFixedCollectionSection) {
const displayName = import_getters.getters.nodeParam.getDisplayName(node);
if (!displayName)
return;
if (displayName.value.toLowerCase().endsWith("or"))
return;
const type = import_getters.getters.nodeParam.getType(node);
if (type?.value === "notice")
return;
if (import_utils.utils.isAllowedLowercase(displayName.value))
return;
const titledCased = (0, import_title_case.titleCase)(displayName.value);
if (displayName.value !== titledCased) {
const fixed = import_utils.utils.keyValue("displayName", titledCased);
context.report({
messageId: "useTitleCase",
node: displayName.ast,
fix: (fixer) => fixer.replaceText(displayName.ast, fixed)
});
}
} else if (isOption) {
const name = import_getters.getters.nodeParam.getName(node);
if (!name)
return;
if (name.value.toLowerCase().endsWith("or"))
return;
if (import_utils.utils.isAllowedLowercase(name.value))
return;
const titleCased = (0, import_title_case.titleCase)(name.value);
if (name.value !== titleCased) {
const fixed = import_utils.utils.keyValue("name", titleCased);
context.report({
messageId: "useTitleCase",
node: name.ast,
fix: (fixer) => fixer.replaceText(name.ast, fixed)
});
}
}
}
};
}
});

View File

@@ -0,0 +1,60 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var node_param_display_name_not_first_position_exports = {};
__export(node_param_display_name_not_first_position_exports, {
default: () => node_param_display_name_not_first_position_default
});
module.exports = __toCommonJS(node_param_display_name_not_first_position_exports);
var import_utils = require("../ast/utils");
var import_identifiers = require("../ast/identifiers");
var import_getters = require("../ast/getters");
var node_param_display_name_not_first_position_default = import_utils.utils.createRule({
name: import_utils.utils.getRuleName(module),
meta: {
type: "problem",
docs: {
description: "By convention, `displayName` in node parameter must be placed first.",
recommended: "strict"
},
fixable: "code",
schema: [],
messages: {
setDisplayNameFirst: "Place `displayName` as first property [non-autofixable]"
}
},
defaultOptions: [],
create(context) {
return {
ObjectExpression(node) {
if (!import_identifiers.id.isNodeParameter(node))
return;
const displayName = import_getters.getters.nodeParam.getDisplayName(node);
if (!displayName)
return;
const [firstProperty] = node.properties;
if (!import_identifiers.id.nodeParam.isDisplayName(firstProperty)) {
context.report({
messageId: "setDisplayNameFirst",
node: displayName.ast
});
}
}
};
}
});

Some files were not shown because too many files have changed in this diff Show More