diff --git a/.github/linters/.hadolint.yaml b/.github/linters/.hadolint.yaml new file mode 100644 index 0000000000..08e1f05154 --- /dev/null +++ b/.github/linters/.hadolint.yaml @@ -0,0 +1,16 @@ +--- +########################## +## Hadolint config file ## +########################## +failure-threshold: "error" +ignored: + - DL4001 # Ignore wget and curl in same file + - DL4006 # ignore pipefail as we don't want to add layers + - DL3018 # Allow unpinned OS package versions (see DL3008 note for APT) + - DL3013 # Allow unpinned pip package versions; versions are managed outside the Dockerfile + - DL3003 # Ignore workdir so we don't add layers + - SC2016 # ignore as its interpreted later + - DL3044 # Ignore using env in env + - DL3008 # Ignore pinned versions check for APT + - SC3020 # Ignore POSIX check of the shorthand redirection(&>) + - SC2283 # Remove spaces around = to assign and this is not needed diff --git a/.github/linters/.shellcheckrc b/.github/linters/.shellcheckrc new file mode 100644 index 0000000000..05da7bf6f6 --- /dev/null +++ b/.github/linters/.shellcheckrc @@ -0,0 +1,3 @@ +shell=bash +disable=SC1101,SC1102 +severity=error diff --git a/.github/linters/eslint.config.mjs b/.github/linters/eslint.config.mjs new file mode 100644 index 0000000000..f89d7ada71 --- /dev/null +++ b/.github/linters/eslint.config.mjs @@ -0,0 +1,55 @@ +import { defineConfig } from "eslint/config"; +import { FlatCompat } from "@eslint/eslintrc"; +import js from "@eslint/js"; +import globals from "globals"; +import jsoncParser from "jsonc-eslint-parser"; + +const compat = new FlatCompat(); + +export default defineConfig([ + js.configs.recommended, + + { + files: ["**/*.js", "**/*.cjs"], + languageOptions: { + ecmaVersion: 2021, + sourceType: "script", + globals: { + ...globals.node, + }, + }, + rules: { + "no-undef": "error", + }, + }, + + { + files: ["build/src/prep.js"], + languageOptions: { + globals: { scriptLibraryPathInRepo: "readonly" }, + }, + }, + + { + files: ["build/src/push.js"], + rules: { + "no-useless-escape": "off", + }, + }, + + { + files: ["build/src/utils/async.js"], + rules: { + "no-redeclare": ["error", { builtinGlobals: false }], + }, + }, + + ...compat.extends("plugin:jsonc/recommended-with-jsonc"), + { + files: ["**/*.json"], + languageOptions: { + parser: jsoncParser, + parserOptions: { jsonSyntax: "JSONC" }, + }, + }, +]); diff --git a/.github/workflows/code-linter.yml b/.github/workflows/code-linter.yml new file mode 100644 index 0000000000..97eafa60bc --- /dev/null +++ b/.github/workflows/code-linter.yml @@ -0,0 +1,32 @@ +name: JSON, shell, javascript and Dockerfile linter + +on: + push: + branches: + - main + pull_request: + +jobs: + code-linter-steps: + name: JSON, shell, javascript and Dockerfile linter + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: super-linter/super-linter/slim@v8 + env: + MULTI_STATUS : false + ENABLE_GITHUB_PULL_REQUEST_SUMMARY_COMMENT: false + BASH_SEVERITY: error + VALIDATE_ALL_CODEBASE: true + DEFAULT_BRANCH: main + FILTER_REGEX_INCLUDE: '(^|.*/)(src/.*|build/.*\.js|Dockerfile)$' + FILTER_REGEX_EXCLUDE: '(^|.*/)src/.*/test-project(/.*)?$' + VALIDATE_DOCKERFILE_HADOLINT: true + VALIDATE_JAVASCRIPT_ES: true + VALIDATE_JSON: true + VALIDATE_BASH: true + diff --git a/build/src/prep.js b/build/src/prep.js index 713ef20d03..ae266693f0 100644 --- a/build/src/prep.js +++ b/build/src/prep.js @@ -7,7 +7,6 @@ const path = require('path'); const asyncUtils = require('./utils/async'); const configUtils = require('./utils/config'); const handlebars = require('handlebars'); -const mkdirp = require('mkdirp'); const scriptSHA = {}; const assetsPath = path.join(__dirname, '..', 'assets');