diff --git a/index.js b/index.js index fb17d0b..5c72534 100644 --- a/index.js +++ b/index.js @@ -118,7 +118,9 @@ module.exports = { return { Literal(node) { - const { value } = node; + const { value, parent } = node; + const nodeIsPropertyName = parent.type === 'Property' && parent.key === node + if (nodeIsPropertyName) return; checkString(value, node); }, TemplateElement(node) { @@ -127,7 +129,9 @@ module.exports = { checkString(value, node); }, JSONLiteral(node){ - const { value } = node; + const { value, parent } = node; + const nodeIsPropertyName = parent.type === 'JSONProperty' && parent.key === node + if (nodeIsPropertyName) return; checkString(value, node); } }; diff --git a/package.json b/package.json index ff9c784..a7055ea 100644 --- a/package.json +++ b/package.json @@ -25,12 +25,12 @@ "eslint-plugin-jsonc": "^0.9.0", "eslint-plugin-self": "^1.2.0", "eslint6": "npm:eslint@^6.8.0", + "lodash": "^4.17.21", "mocha": "^7.1.1" }, "peerDependencies": { "eslint": ">=3.0.0" }, - "dependencies": {}, "engines": { "npm": ">=6.9.0", "node": ">=10.0.0" diff --git a/tests/lib/rules/no-secrets.js b/tests/lib/rules/no-secrets.js index 21f5517..da7d76c 100644 --- a/tests/lib/rules/no-secrets.js +++ b/tests/lib/rules/no-secrets.js @@ -42,6 +42,13 @@ const VAULT = { const CSS_CLASSNAME = ` const CSS_CLASSNAME = "hey-it-s-a-css-class-not-a-secret and-neither-this-one"; `; + +const PROPERTY_NAME = ` +const VAULT = { + "ZWVTjPQSdhwRgl204Hc51YCsritMIzn8B=/p9UyeX7xu6KkAGqfm3FJ+oObLDNEva": "not a secret" +} +`; + const IGNORE_CONTENT_TEST = ` const BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; `; @@ -117,6 +124,10 @@ const TESTS = { code: CSS_CLASSNAME, options: [] }, + { + code: PROPERTY_NAME, + options: [] + }, { code: IGNORE_CONTENT_TEST, options: [{ ignoreContent: [/^ABC/] }]