Skip to content

Commit

Permalink
feat(actions): add lint and changelog (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML authored Jun 29, 2023
1 parent e8e60af commit 7c22218
Show file tree
Hide file tree
Showing 10 changed files with 1,219 additions and 348 deletions.
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"root": true,
"plugins": ["unicorn"],
"extends": ["eslint:recommended"],
"rules": {
"no-console": "off",
"no-use-before-define": ["error", "nofunc"],
"no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^(e|_.*)$",
"vars": "local",
"varsIgnorePattern": "(debug|^_)"
}
],
"prefer-const": "error",
"react/jsx-boolean-value": ["error", "always"],
"unicorn/better-regex": "warn",
"unicorn/expiring-todo-comments": "error",
"unicorn/no-abusive-eslint-disable": "error"
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"settings": {}
}
35 changes: 35 additions & 0 deletions .github/changelog-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["feature"]
},
{
"title": "## 🐛 Fixes",
"labels": ["fix"]
},
{
"title": "## 🧪 Tests",
"labels": ["test"]
}
],
"ignore_labels": ["ignore_changelog"],
"sort": "ASC",
"template": "${{CHANGELOG}}\n\n<details open>\n<summary>Uncategorized</summary>\n\n${{UNCATEGORIZED}}\n</details>",
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
"empty_template": "- no changes",
"label_extractor": [
{
"pattern": "\\[Issue\\]",
"on_property": "title",
"method": "match"
}
],
"transformers": [],
"max_tags_to_fetch": 200,
"max_pull_requests": 200,
"max_back_track_time_days": 365,
"exclude_merge_branches": [],
"tag_resolver": {},
"base_branches": []
}
30 changes: 30 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "changelog"
on:
push:
tags:
- "*"

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v2
with:
configuration: ".github/changelog-configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{steps.github_release.outputs.changelog}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 20

- name: Install Node.js dependencies
run: yarn

- name: Run ESLint/Flow/Prettier
run: yarn lint
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "auto"
}
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# babel-watch

Reload your babel-node app on JS source file changes. And do it *fast*.
Reload your babel-node app on JS source file changes. And do it _fast_.

## Why should I use it?

Expand All @@ -19,18 +19,21 @@ Currently `babel-watch` is supported on Linux, OSX and Windows.
Just install it and add to your package:

With NPM:

```bash
npm install --save-dev babel-watch
```

With Yarn:

```bash
yarn add --dev babel-watch
```

(Make sure you have `@babel/core` installed as dependency in your project as `babel-watch` only defines `@babel/core` as a "peerDependency")

Then use `babel-watch` in your `package.json` in scripts section like this:

```json
"scripts": {
"start": "babel-watch src/main.js"
Expand Down Expand Up @@ -119,21 +122,21 @@ Using `babel-node` or `babel-watch` is not recommended in production environment

`babel-watch`'s versions now mirror the major version range of the Babel version it is compatible with. Currently, that is `7.x`.

* `babel-watch >= 2.0.7` (and now `7.x`) is compatible with `@babel/core` version `7.0.0` and above
* `babel-watch < 2.0.7 && >= 2.0.2` is compatible with `babel-core` version `6.5.1`
* `babel-watch <= 2.0.1` is compatible with `babel-core` from `6.4.x` up to `6.5.0`
- `babel-watch >= 2.0.7` (and now `7.x`) is compatible with `@babel/core` version `7.0.0` and above
- `babel-watch < 2.0.7 && >= 2.0.2` is compatible with `babel-core` version `6.5.1`
- `babel-watch <= 2.0.1` is compatible with `babel-core` from `6.4.x` up to `6.5.0`

*(This is due to the babel's "option manager" API change in `babel-core@6.5.1`)*
_(This is due to the babel's "option manager" API change in `babel-core@6.5.1`)_

## What's the difference between `--ignore` and `--exclude`?

These options seem very similar, and so there is [some confusion](https://github.com/kmagiera/babel-watch/issues/121) about them. The difference is:

* `--ignore` will watch the file, but not transpile it with Babel.
* Use if you have JS files in your project that are not transpiled or handled by some other tool, but you still want to restart when they change.
* This is called `--ignore` to mirror the Babel option.
* `--exclude` will not watch the file at all and thus it won't be transpiled either.
* Use if you want the watcher to exclude these files entirely. They will not be watched or rebuilt at all. For many projects, judicious use of `--exclude` can really speed things up.
- `--ignore` will watch the file, but not transpile it with Babel.
- Use if you have JS files in your project that are not transpiled or handled by some other tool, but you still want to restart when they change.
- This is called `--ignore` to mirror the Babel option.
- `--exclude` will not watch the file at all and thus it won't be transpiled either.
- Use if you want the watcher to exclude these files entirely. They will not be watched or rebuilt at all. For many projects, judicious use of `--exclude` can really speed things up.

## Troubleshooting

Expand All @@ -152,7 +155,7 @@ There are a couple of reasons that could be causing that:

You perhaps are using autowatch. Apparently since view templates are not loaded using `require` command but with `fs.read` instead, therefore autowatch is not able to detect that they are being used. You can still use autowatch for all the js sources, but need to specify the directory name where you keep your view templates so that changes in these files can trigger app restart. This can be done using `--watch` option (e.g. `babel-watch --watch views app.js`).

#### I'm getting an error: *Cannot find module '@babel/core'*
#### I'm getting an error: _Cannot find module '@babel/core'_

`babel-watch` does not have `@babel/core` listed as a direct dependency but as a "peerDependency". If you're using `babel` in your app you should already have `@babel/core` installed. If not you should do `npm install --save-dev @babel/core`. We decided not to make `@babel/core` a direct dependency as in some cases having it defined this way would make your application pull two versions of `@babel/core` from `npm` during installation and since `@babel/core` is quite a huge package that's something we wanted to avoid.

Expand Down
Loading

0 comments on commit 7c22218

Please sign in to comment.