Skip to content

Commit

Permalink
feat: initial release (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi authored Feb 8, 2025
1 parent c59f1e8 commit 4cf5b16
Show file tree
Hide file tree
Showing 19 changed files with 9,570 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const config = {
extends: ['@commitlint/config-conventional'],
rules: {
'footer-max-line-length': [1, 'always', 72],
},
};

export default config;
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[*]
indent_style = tab
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.yml]
indent_style = space
indent_size = 2
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
time: "00:00"
timezone: "Etc/UTC"

- package-ecosystem: npm
directory: /
schedule:
interval: daily
time: "00:00"
timezone: "Etc/UTC"
rebase-strategy: auto
versioning-strategy: increase
commit-message:
prefix: "fix(deps)"
prefix-development: "chore(deps)"
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: "CI"

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Enable corepack'
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'

- name: "Install dependencies"
run: yarn install --immutable

- name: "Build"
run: yarn build

- name: "Lint"
run: yarn lint -f ./dist/index.js

build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Enable corepack'
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'

- name: "Install dependencies"
run: yarn install --immutable

- name: "Build"
run: yarn build

dependabot-merge:
name: "Dependabot automerge"
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
needs: [ "build", "lint" ]
if: github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'
steps:
- uses: fastify/github-action-merge-dependabot@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

semantic-release:
name: "Release"
runs-on: ubuntu-latest
needs: [ "build", "lint" ]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
outputs:
new-release-published: ${{ steps.release.outputs.new-release-published }}
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
ref: "master"
- name: 'Enable corepack'
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'yarn'

- name: Install dependencies
run: yarn install --immutable

- name: "disable postinstall"
run: yarn pinst --disable

- name: "Build"
run: yarn build

- name: "Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn semantic-release
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.idea
.vscode
node_modules
dist
coverage

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
7 changes: 7 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [ "$CI" = "true" ]
then
# disable commitlint for CI environments
exit 0
else
yarn commitlint --edit
fi
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{js,ts,json,yml}": "yarn lint:fix",
"*.md": "yarn lint:fix"
}
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!/dist/**
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ver0Cfg from '@ver0/eslint-config/.prettierrc.js';

/**
* @type {import("prettier").Config}
*/
export default {
...ver0Cfg,
};
11 changes: 11 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div align="center">

# ESLint Formatter for GitHub Actions

[![NPM Version](https://flat.badgen.net/npm/v/@react-hookz/eslint-formatter-gha)](https://www.npmjs.com/package/@react-hookz/eslint-formatter-gha)
[![NPM Downloads](https://flat.badgen.net/npm/dm/@react-hookz/eslint-formatter-gha)](https://www.npmjs.com/package/@react-hookz/eslint-formatter-gha)
[![NPM Dependents](https://flat.badgen.net/npm/dependents/@react-hookz/eslint-formatter-gha)](https://www.npmjs.com/package/@react-hookz/eslint-formatter-gha)
[![Build](https://img.shields.io/github/actions/workflow/status/react-hookz/eslint-formatter-gha/ci-cd.yml?branch=master&style=flat-square)](https://github.com/react-hookz/eslint-formatter-gha/actions)
[![Types](https://flat.badgen.net/npm/types/@react-hookz/eslint-formatter-gha)](https://www.npmjs.com/package/@react-hookz/eslint-formatter-gha)

</div>

---

Custom formatter for ESLint that generates GitHub Actions annotations.

## Install

This one is pretty simple, everyone knows what to do:

```shell
npm i --save-dev @react-hookz/eslint-formatter-gha
# or
yarn add -D @react-hookz/eslint-formatter-gha
```

## Usage

```shell
eslint -f @react-hookz/gha
```
19 changes: 19 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {buildConfig} from '@ver0/eslint-config';

/** @typedef {import('eslint').Linter} Linter */

/** @type {Linter.Config[]} */
const cfg = [
{ignores: ['dist/**/*']},
...buildConfig({
globals: 'node',
react: true,
vitest: true,
}),
{
files: ['README.md'],
language: 'markdown/gfm',
},
];

export default cfg;
57 changes: 57 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@ver0/eslint-formatter-gha",
"description": "ESLint formatter for Github Actions",
"version": "1.0.0",
"keywords": [
"eslint",
"formatter",
"eslint-formatter",
"guthub-actions"
],
"repository": {
"type": "git",
"url": "https://github.com/ver0-project/eslint-formatter-gha"
},
"bugs": {
"url": "https://github.com/ver0-project/eslint-formatter-gha/issues"
},
"publishConfig": {
"access": "public"
},
"license": "MIT",
"author": "Anton Zinovyev <[email protected]>",
"engines": {
"node": ">=18"
},
"type": "module",
"files": [
"dist"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"postinstall": "husky",
"build": "yarn build:clean && yarn tsc -p tsconfig.build.json",
"build:clean": "rimraf dist",
"lint": "eslint",
"lint:fix": "eslint --fix"
},
"packageManager": "[email protected]",
"dependencies": {
"@actions/core": "^1.11.1"
},
"devDependencies": {
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"@types/eslint": "^9.6.1",
"@types/node": "^22.13.1",
"@ver0/eslint-config": "^1.1.1",
"eslint": "^9.20.0",
"husky": "^9.1.7",
"lint-staged": "^15.4.3",
"pinst": "^3.0.0",
"rimraf": "^6.0.1",
"semantic-release": "^24.2.1",
"typescript": "^5.7.3"
}
}
33 changes: 33 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {endGroup, error, notice, startGroup, warning} from '@actions/core';
import type {ESLint} from 'eslint';

const severityActor = [notice, warning, error];

const GHAFormatter: ESLint.Formatter['format'] = (results) => {
startGroup('Lint Annotations');

for (const result of results) {
for (const message of result.messages) {
const actor = severityActor[message.severity];
if (!actor) {
warning(`Unknown eslint severity: ${message.severity}`);

continue;
}

actor(`${message.message} (${message.ruleId})`, {
file: result.filePath,
startLine: message.line,
endLine: message.endLine,
startColumn: message.column,
endColumn: message.endColumn,
});
}
}

endGroup();

return '';
};

export default GHAFormatter;
13 changes: 13 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"outDir": "./dist"
},
"include": [
"src"
],
"exclude": [
"src/**/*.test.ts"
]
}
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitThis": true,
"skipLibCheck": true
},
"exclude": [
"node_modules",
"dist",
".yarn",
".pnp.cjs",
".pnp.loader.mjs"
]
}
Loading

0 comments on commit 4cf5b16

Please sign in to comment.