From a9dba2b4e62a5674ba5b35672ca091f10cf90e6c Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 19 May 2021 01:22:29 -0400 Subject: [PATCH] Added converter for non-literal-fs-path --- .../lintConfigs/rules/ruleConverters.ts | 2 ++ .../ruleConverters/non-literal-fs-path.ts | 12 ++++++++++++ .../tests/non-literal-fs-path.test.ts | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/converters/lintConfigs/rules/ruleConverters/non-literal-fs-path.ts create mode 100644 src/converters/lintConfigs/rules/ruleConverters/tests/non-literal-fs-path.test.ts diff --git a/src/converters/lintConfigs/rules/ruleConverters.ts b/src/converters/lintConfigs/rules/ruleConverters.ts index 093edb285..da303e1ee 100644 --- a/src/converters/lintConfigs/rules/ruleConverters.ts +++ b/src/converters/lintConfigs/rules/ruleConverters.ts @@ -73,6 +73,7 @@ import { convertNoMagicNumbers } from "./ruleConverters/no-magic-numbers"; import { convertNoMisusedNew } from "./ruleConverters/no-misused-new"; import { convertNoMultilineString } from "./ruleConverters/no-multiline-string"; import { convertNoNamespace } from "./ruleConverters/no-namespace"; +import { convertNonLiteralFsPath } from "./ruleConverters/non-literal-fs-path"; import { convertNoNonNullAssertion } from "./ruleConverters/no-non-null-assertion"; import { convertNoNullKeyword } from "./ruleConverters/no-null-keyword"; import { convertNoObjectLiteralTypeAssertion } from "./ruleConverters/no-object-literal-type-assertion"; @@ -330,6 +331,7 @@ export const ruleConverters = new Map([ ["no-misused-new", convertNoMisusedNew], ["no-multiline-string", convertNoMultilineString], ["no-namespace", convertNoNamespace], + ["non-literal-fs-path", convertNonLiteralFsPath], ["no-non-null-assertion", convertNoNonNullAssertion], ["no-null-keyword", convertNoNullKeyword], ["no-object-literal-type-assertion", convertNoObjectLiteralTypeAssertion], diff --git a/src/converters/lintConfigs/rules/ruleConverters/non-literal-fs-path.ts b/src/converters/lintConfigs/rules/ruleConverters/non-literal-fs-path.ts new file mode 100644 index 000000000..74c8c34a4 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/non-literal-fs-path.ts @@ -0,0 +1,12 @@ +import { RuleConverter } from "../ruleConverter"; + +export const convertNonLiteralFsPath: RuleConverter = () => { + return { + plugins: ["eslint-plugin-security"], + rules: [ + { + ruleName: "security/detect-non-literal-fs-filename", + }, + ], + }; +}; diff --git a/src/converters/lintConfigs/rules/ruleConverters/tests/non-literal-fs-path.test.ts b/src/converters/lintConfigs/rules/ruleConverters/tests/non-literal-fs-path.test.ts new file mode 100644 index 000000000..fe0d18a21 --- /dev/null +++ b/src/converters/lintConfigs/rules/ruleConverters/tests/non-literal-fs-path.test.ts @@ -0,0 +1,18 @@ +import { convertNonLiteralFsPath } from "../non-literal-fs-path"; + +describe(convertNonLiteralFsPath, () => { + test("conversion without arguments", () => { + const result = convertNonLiteralFsPath({ + ruleArguments: [], + }); + + expect(result).toEqual({ + plugins: ["eslint-plugin-security"], + rules: [ + { + ruleName: "security/detect-non-literal-fs-filename", + }, + ], + }); + }); +});