├── .editorconfig ├── MAINTENANCE ├── .github ├── renovate.json └── workflows │ └── ci.yml ├── .yamllint.yml ├── oxlint.sh ├── action.yml └── README.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | [*.yml] 3 | indent_size = 2 4 | -------------------------------------------------------------------------------- /MAINTENANCE: -------------------------------------------------------------------------------- 1 | # Make a new release 2 | 3 | * Visit [Draft a new release](https://github.com/oxc-project/oxlint-action/releases/new) 4 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": ["github>Boshen/renovate"] 4 | } 5 | -------------------------------------------------------------------------------- /.yamllint.yml: -------------------------------------------------------------------------------- 1 | extends: default 2 | rules: 3 | line-length: disable 4 | document-start: disable 5 | # Hitting false positives with 'on' key. 6 | truthy: disable 7 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | types: [opened, synchronize] 7 | push: 8 | branches: 9 | - main 10 | 11 | permissions: {} 12 | 13 | jobs: 14 | check: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1 18 | 19 | - uses: crate-ci/typos@2d0ce569feab1f8752f1dde43cc2f2aa53236e06 # v1.40.0 20 | 21 | - uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0 22 | 23 | - uses: oxc-project/oxlint-action@92eec2c4d5dbbb882c926478438aa4b7f20ffe2d # v3.0.0 24 | -------------------------------------------------------------------------------- /oxlint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -o pipefail 4 | 5 | # config 6 | if [ -n "$OXLINT_CONFIG" ]; then 7 | # check if config file exists 8 | if [ ! -f "$OXLINT_CONFIG" ]; then 9 | echo "::error file={$OXLINT_CONFIG}::Config file not found: $OXLINT_CONFIG" 10 | exit 1 11 | 12 | # check if the config file is js, which is not supported 13 | elif [ "${OXLINT_CONFIG##*.}" = "js" ]; then 14 | echo "::error file={$OXLINT_CONFIG}::Oxlint only supports JSON files. Please convert your config file to JSON." 15 | exit 1 16 | fi 17 | 18 | config="--config $OXLINT_CONFIG" 19 | fi 20 | 21 | OXLINT_ARGS="$config" 22 | 23 | # Build plugin args 24 | # map whitespace-separated `name` to `--name-plugin` 25 | if [ -n "$OXLINT_PLUGINS" ]; then 26 | plugins="$(echo "$OXLINT_PLUGINS" | xargs | sed -e 's/ /-plugin --/g' -e 's/^/--/')-plugin" 27 | fi 28 | 29 | # build disable plugin args 30 | # map whitespace-separated `name` to `--disable-name-plugin` 31 | if [ -n "$OXLINT_PLUGINS_DISABLE" ]; then 32 | disable_plugins="$(echo "$OXLINT_PLUGINS_DISABLE" | xargs | sed -e 's/ /-plugin --disable-/g' -e 's/^/--disable-/')-plugin" 33 | fi 34 | 35 | OXLINT_ARGS="$OXLINT_ARGS $plugins $disable_plugins" 36 | 37 | # build allow, warn, and deny lists 38 | # map `rule-name` to `-[A/W/D] rule-name` 39 | if [ -n "$OXLINT_ALLOW" ]; then 40 | allow_list="$(echo "$OXLINT_ALLOW" | xargs | sed -e 's/ / -A /g' -e 's/^/-A /')" 41 | fi 42 | 43 | if [ -n "$OXLINT_WARN" ]; then 44 | warn_list="$(echo "$OXLINT_WARN" | xargs | sed -e 's/ / -W /g' -e 's/^/-W /')" 45 | fi 46 | 47 | if [ -n "$OXLINT_DENY" ]; then 48 | deny_list="$(echo "$OXLINT_DENY" | xargs | sed -e 's/ / -D /g' -e 's/^/-D /')" 49 | fi 50 | 51 | # order is important. We want consumers to be able to deny a category, and then 52 | # allow single rules as needed. 53 | OXLINT_ARGS="$OXLINT_ARGS $warn_list $deny_list $allow_list" 54 | 55 | # build deny warnings and max warnings args 56 | if [ -n "$OXLINT_MAX_WARNINGS" ]; then 57 | OXLINT_ARGS="$OXLINT_ARGS --max-warnings $OXLINT_MAX_WARNINGS" 58 | fi 59 | 60 | if [ "$OXLINT_DENY_WARNINGS" = "true" ]; then 61 | OXLINT_ARGS="$OXLINT_ARGS --deny-warnings" 62 | fi 63 | 64 | # use github output format 65 | OXLINT_ARGS="$OXLINT_ARGS --format github" 66 | 67 | echo "::debug::Args: $OXLINT_ARGS" 68 | 69 | 70 | # Files to lint are passed as arguments. For non-prs, no arguments are passed, 71 | # which defaults to all VCS files. 72 | # shellcheck disable=SC2068,SC2086 73 | npx oxlint@$OXLINT_VERSION $OXLINT_ARGS ${@:1} 74 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Oxlint Action" 2 | description: "Lint your code with Oxlint" 3 | author: Oxc Contributors 4 | branding: 5 | icon: anchor 6 | color: blue 7 | 8 | inputs: 9 | version: 10 | description: "Oxlint SemVer version pattern to use" 11 | required: false 12 | default: "latest" 13 | 14 | allow: 15 | description: "Categories and lints to allow, separated by whitespace" 16 | required: false 17 | default: "" 18 | 19 | deny: 20 | description: "Categories and lints to deny, separated by whitespace" 21 | required: false 22 | default: "" 23 | 24 | warn: 25 | description: "Categories and lints to warn about, separated by whitespace" 26 | required: false 27 | default: "" 28 | 29 | max-warnings: 30 | description: "Maximum number of warnings allowed. By default, no maximum is enforced." 31 | required: false 32 | 33 | deny-warnings: 34 | description: "Fail the check if there are any warnings." 35 | required: false 36 | default: "false" 37 | 38 | plugins: 39 | description: "Comma-separated list of plugins to enable" 40 | required: false 41 | default: "" 42 | 43 | plugins-disable: 44 | description: "Comma-separated list of plugins to disable" 45 | required: false 46 | default: "" 47 | 48 | config: 49 | description: "Path to Oxlint or ESLint configuration file. Only JSON is supported." 50 | required: false 51 | default: "" 52 | 53 | all-files: 54 | description: "Lint all files, not just changed ones. Only affects PRs." 55 | required: false 56 | default: "false" 57 | 58 | base-branch: 59 | description: "Base branch to diff PR branches against." 60 | required: false 61 | default: "" # Default to PR target branch 62 | 63 | working-directory: 64 | description: "Working directory to run oxlint in." 65 | required: false 66 | default: "" 67 | 68 | runs: 69 | using: "composite" 70 | steps: 71 | - name: Set Base Branch 72 | id: base-branch 73 | shell: bash 74 | if: github.event_name == 'pull_request' 75 | run: | 76 | if [ -z "${{ inputs.base-branch }}" ]; then 77 | echo "Base branch not set. Defaulting to target branch of PR." 78 | echo "base-branch=${{ github.event.pull_request.base.ref }}" >> "$GITHUB_OUTPUT" 79 | else 80 | echo "base-branch=${{ inputs.base-branch }}" >> "$GITHUB_OUTPUT" 81 | fi 82 | 83 | - name: Fetch Base Branch 84 | shell: bash 85 | if: github.event_name == 'pull_request' 86 | run: | 87 | git fetch origin $BASE_BRANCH:$BASE_BRANCH --depth=1 88 | # git branch --track $BASE_BRANCH origin/$BASE_BRANCH 89 | env: 90 | BASE_BRANCH: ${{ steps.base-branch.outputs.base-branch }} 91 | 92 | - name: Check For NPX 93 | shell: bash 94 | run: | 95 | if ! command -v npx &> /dev/null 96 | then 97 | echo "::error title=Node.js not found::npx could not be found. Please install Node.js." 98 | exit 1 99 | fi 100 | 101 | - name: Run Oxlint (Changed Files) 102 | shell: bash 103 | if: github.event_name == 'pull_request' && inputs.all-files == 'false' 104 | working-directory: ${{ inputs.working-directory }} 105 | run: | 106 | echo "::group::Run Oxlint (Changed Files)" 107 | files=$(git diff --name-only --relative ${{ steps.base-branch.outputs.base-branch }} ${{ github.sha }}) 108 | echo "::debug::Files:" 109 | echo "::debug::${files}" 110 | $GITHUB_ACTION_PATH/oxlint.sh $files 111 | echo "::endgroup::" 112 | env: 113 | OXLINT_VERSION: ${{ inputs.version }} 114 | OXLINT_DENY: ${{ inputs.deny }} 115 | OXLINT_WARN: ${{ inputs.warn }} 116 | OXLINT_ALLOW: ${{ inputs.allow }} 117 | OXLINT_MAX_WARNINGS: ${{ inputs.max-warnings }} 118 | OXLINT_DENY_WARNINGS: ${{ inputs.deny-warnings }} 119 | OXLINT_PLUGINS: ${{ inputs.plugins }} 120 | OXLINT_PLUGINS_DISABLE: ${{ inputs.plugins-disable }} 121 | OXLINT_CONFIG: ${{ inputs.config }} 122 | 123 | - name: Run Oxlint (All Files) 124 | shell: bash 125 | if: github.event_name != 'pull_request' || inputs.all-files == 'true' 126 | working-directory: ${{ inputs.working-directory }} 127 | run: | 128 | echo "::group::Run Oxlint (All Files)" 129 | $GITHUB_ACTION_PATH/oxlint.sh 130 | echo "::endgroup::" 131 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |