Skip to content

Commit

Permalink
Merge pull request #37 from stropho/prettier
Browse files Browse the repository at this point in the history
chore: use prettier
  • Loading branch information
stropho authored Apr 4, 2024
2 parents 0050c4a + 15fb80f commit 43e78c4
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 57 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# un-ingnore dot files - eslint ignores them by default
!.*.js

dist/
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
jest: true,
es6: true,
},
extends: 'airbnb-base',
extends: ['airbnb-base', 'plugin:prettier/recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
Expand All @@ -13,8 +13,7 @@ module.exports = {
sourceType: 'module',
},
rules: {
'semi': ['error', 'never'],
'import/prefer-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
},
};
}
6 changes: 3 additions & 3 deletions .github/workflows/bump-push-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
inputs:
release-type:
type: choice
options:
options:
- patch
- minor
- major
Expand All @@ -30,7 +30,7 @@ jobs:
node-version: '20'
- run: npm ci
- run: npm run build

- name: Git configuration
run: |
git config --global user.email "github-action@users.noreply.github.com"
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Push bumped files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# push tags, and HEAD to the tracked remote branch (=push the branch)
# push tags, and HEAD to the tracked remote branch (=push the branch)
run: git push --tags origin HEAD
- run: npm publish
env:
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/nodejs.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@ name: Node.js CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version:
node-version:
- 14.17.x
- 16.x
- 18.x
- 20.x

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
env:
CI: true
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
env:
CI: true
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'*.{ts,tsx,js,jsx,cjs,mjs,json,md,html,yml,yaml}': 'prettier --write',
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
jsxSingleQuote: true,
semi: false,
singleQuote: true,
trailingComma: 'all',
}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,56 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]

## [1.2.3] - 2024-03-28

### Added

- **Contributing** section in README
- MIT `LICENSE` file

### Security

- update devDependencies and resolve security vulnerabilities

## [1.2.2] - 2021-03-19

### Removed

- `npm` version from `engines` field in package.json. At this moment, there isn't any specific case why a specific subset of `npm` versions is needed

## [1.2.1] - 2021-02-24

### Added

- typescript definition file in published package

## [1.2.0] - 2021-02-24

### Added

- support for banner as an object with `toString` method

## [1.1.0] - 2021-02-24

### Added

- support newer node version

## [1.0.2] - 2020-12-13

### Changed

- npm audit fix

## [1.0.1] - 2020-12-09

### Changed

- publish only files in dist/

## 1.0.0 - 2020-03-19

### Added

- Initial Implementation
- Readme
- sourcemap support
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ import banner2 from 'rollup-plugin-banner2'

export default {
plugins: [
banner2(() => `
banner2(
() => `
/**
* rollup-plugin-banner2
*/
`)
]
`,
),
],
}

```

## Comparison with `rollup-plugin-banner`

- `banner2` supports sourcemaps
- `banner2` supports adding different banner to different chunks based on `ChunkInfo` (for more info see https://rollupjs.org/ )
- `banner2` does not support file path option that loads a file content and uses that as a banner. It should be easy enough to call `fs.readFileSync` yourself
Expand All @@ -50,7 +52,9 @@ The missing features could be added if someone actually needs them.
```ts
banner2(resolveBanner, options)
```

The `resolveBanner` function returns a banner as

- `string`
- stringifiable object, i.e. having `toString` method, such as `Buffer`
- any falsy value for an empty banner
Expand All @@ -60,7 +64,7 @@ For more details see the [typescript definition](index.d.ts)

## Contributing

- new PRs accepted :-)
- always cover your changes by tests
- always mention your changes in the [CHANGELOG.md](CHANGELOG.md)
- always update [typescript definition](index.d.ts) file when relevant to your changes
- new PRs accepted :-)
- always cover your changes by tests
- always mention your changes in the [CHANGELOG.md](CHANGELOG.md)
- always update [typescript definition](index.d.ts) file when relevant to your changes
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as rollup from 'rollup';
import * as rollup from 'rollup'

type Falsy = false | 0 | "" | null | undefined
type Falsy = false | 0 | '' | null | undefined

type Stringifiable = {toString: () => string}
type Stringifiable = { toString: () => string }

/**
* The `resolveBanner` function returns a banner as
Expand All @@ -14,13 +14,13 @@ type Stringifiable = {toString: () => string}
type ResolveBanner = (
chunk: rollup.RenderedChunk,
options: rollup.OutputOptions,
) => string| Falsy | Stringifiable | Promise<string|Falsy|Stringifiable>
) => string | Falsy | Stringifiable | Promise<string | Falsy | Stringifiable>

type Options = {
sourcemap?: boolean,
sourcemap?: boolean
}

declare function banner2 (
declare function banner2(
resolveBanner: ResolveBanner,
options?: Options,
): rollup.Plugin
Expand Down
Loading

0 comments on commit 43e78c4

Please sign in to comment.