From 0e03102b3e5a35a6edf87a91ee70fb4f4844665a Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 6 Aug 2020 19:48:44 -0500 Subject: [PATCH 1/2] Add airbnb config, and pretier plugin for eslint --- dependencies/package-lock.json | 46 ++++++++++++++++++++++++++++++++++ dependencies/package.json | 2 ++ 2 files changed, 48 insertions(+) diff --git a/dependencies/package-lock.json b/dependencies/package-lock.json index ba9b484d..1eea3938 100644 --- a/dependencies/package-lock.json +++ b/dependencies/package-lock.json @@ -1152,6 +1152,11 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "confusing-browser-globals": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz", + "integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==" + }, "contains-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", @@ -1751,6 +1756,26 @@ } } }, + "eslint-config-airbnb": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-18.2.0.tgz", + "integrity": "sha512-Fz4JIUKkrhO0du2cg5opdyPKQXOI2MvF8KUvN2710nJMT6jaRUpRE2swrJftAjVGL7T1otLM5ieo5RqS1v9Udg==", + "requires": { + "eslint-config-airbnb-base": "^14.2.0", + "object.assign": "^4.1.0", + "object.entries": "^1.1.2" + } + }, + "eslint-config-airbnb-base": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.2.0.tgz", + "integrity": "sha512-Snswd5oC6nJaevs3nZoLSTvGJBvzTfnBqOIArkf3cbyTyq9UD79wOk8s+RiL6bhca0p/eRO6veczhf6A/7Jy8Q==", + "requires": { + "confusing-browser-globals": "^1.0.9", + "object.assign": "^4.1.0", + "object.entries": "^1.1.2" + } + }, "eslint-config-prettier": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz", @@ -2032,6 +2057,14 @@ } } }, + "eslint-plugin-prettier": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz", + "integrity": "sha512-jZDa8z76klRqo+TdGDTFJSavwbnWK2ZpqGKNZ+VvweMW516pDUMmQ2koXvxEE4JhzNvTv+radye/bWGBmA6jmg==", + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-plugin-promise": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz", @@ -2176,6 +2209,11 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==" + }, "fast-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.1.0.tgz", @@ -4463,6 +4501,14 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==" }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "requires": { + "fast-diff": "^1.1.2" + } + }, "prettyjson": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prettyjson/-/prettyjson-1.2.1.tgz", diff --git a/dependencies/package.json b/dependencies/package.json index fdd6aa9e..0031d97c 100644 --- a/dependencies/package.json +++ b/dependencies/package.json @@ -9,8 +9,10 @@ "babel-eslint": "^10.1.0", "dockerfilelint": "^1.5.0", "eslint": "^7.6.0", + "eslint-config-airbnb": "^18.2.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-jest": "^23.20.0", + "eslint-plugin-prettier": "^3.1.4", "htmlhint": "^0.14.1", "jsonlint": "^1.6.3", "markdownlint-cli": "^0.23.2", From a186477c8b2066240c774c46b43bef4342881a14 Mon Sep 17 00:00:00 2001 From: Gabo Date: Thu, 6 Aug 2020 19:49:23 -0500 Subject: [PATCH 2/2] Skip node_modules from finds --- lib/linter.sh | 8 ++++---- lib/worker.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 6c689b85..e3efa99c 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1261,7 +1261,7 @@ if [ "${VALIDATE_ARM}" == "true" ]; then ############################################################################### IFS=$'\n' - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(json\)\$" 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(json\)\$" 2>&1) for FILE in "${LIST_FILES[@]}"; do if DetectARMFile "${FILE}"; then FILE_ARRAY_ARM+=("${FILE}") @@ -1303,7 +1303,7 @@ if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then ############################################################################### IFS=$'\n' - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) for FILE in "${LIST_FILES[@]}"; do if DetectCloudFormationFile "${FILE}"; then FILE_ARRAY_CLOUDFORMATION+=("${FILE}") @@ -1557,7 +1557,7 @@ if [ "${VALIDATE_OPENAPI}" == "true" ]; then ############################################################################### IFS=$'\n' - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1) for FILE in "${LIST_FILES[@]}"; do if DetectOpenAPIFile "${FILE}"; then FILE_ARRAY_OPENAPI+=("${FILE}") @@ -1709,7 +1709,7 @@ if [ "${VALIDATE_STATES}" == "true" ]; then ############################################################################### IFS=$'\n' - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex ".*\.\(json\)\$" 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(json\)\$" 2>&1) for FILE in "${LIST_FILES[@]}"; do if DetectAWSStatesFIle "${FILE}"; then FILE_ARRAY_STATES+=("${FILE}") diff --git a/lib/worker.sh b/lib/worker.sh index 434fe2f0..f560722f 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -85,7 +85,7 @@ function LintCodebase() { ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -type f -regex "${FILE_EXTENSIONS}" 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex "${FILE_EXTENSIONS}" 2>&1) ########################### # Set IFS back to default # @@ -312,7 +312,7 @@ function TestCodebase() { ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -path "*/node_modules" -prune -o -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) ######################################## # Prepare context if TAP output format #