diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ec077e0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: linting + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - name: Install dependencies + run: npm i + + - name: Lint + run: npm run -s lint -- --format=./eslint-gh-annotations-formatter.mjs --quiet diff --git a/eslint-gh-annotations-formatter.mjs b/eslint-gh-annotations-formatter.mjs new file mode 100644 index 0000000..c55a357 --- /dev/null +++ b/eslint-gh-annotations-formatter.mjs @@ -0,0 +1,10 @@ +export default function (results) { + return results + .flatMap(({ filePath, messages }) => + messages.map( + ({ message, line, column }) => + `::error file=${filePath},line=${line},col=${column}::${message}`, + ), + ) + .join("\n"); +}