Skip to content

Commit

Permalink
[#1] Rewrite from scratch
Browse files Browse the repository at this point in the history
- Use` rollup-plugin-prettier` as example
- Replace `jest` with `ava`
- Generate TypeScript declaration files. Added `tsconfig.json` for that purpose
- Wire up `prettier` and enhance ESLint configuration
- Remove `.travis.yml` because of switching to GitHub Actions
- Add `jsconfig.json` form improved JS typing
- Set `rollup` and `eslint` as peer dependencies
- Update dependencies
  • Loading branch information
nikolay-borzov authored Jan 24, 2021
1 parent 89865fc commit 28362e1
Show file tree
Hide file tree
Showing 26 changed files with 9,313 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
},
root: true,
ignorePatterns: [
'**/*.*',
'!**/*.js',
'tests/fixtures',
'node_modules',
'dist',
],
env: {
node: true,
},
plugins: ['prettier', 'standard', 'jsdoc'],
extends: [
'standard',
'prettier',
'plugin:prettier/recommended',
'prettier/standard',
'plugin:node/recommended',
'plugin:jsdoc/recommended',
],
settings: {
jsdoc: {
mode: 'typescript',
},
},
rules: {
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns-description': 'off',
'node/no-unsupported-features/es-syntax': [
'error',
{
ignores: ['modules'],
},
],
},
}
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

strategy:
matrix:
node-version: [12.x, 14.x]
os: [ windows-latest, ubuntu-latest, macos-latest ]

runs-on: ${{ matrix.os }}

steps:
- run: git config --global core.autocrlf input
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
30 changes: 30 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to NPM

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode
/node_modules
coverage
.nyc_output
dist
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package.json
package-lock.json
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
printWidth: 80,
singleQuote: true,
semi: false,
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# rollup-plugin-eslint-bundle changelog

## 6.0.0 - 2021-01-24
* Rewrite from scratch for latest `rollup` and `ESLint`
* Replace `jest` with `ava`
* Require Node.js version >= 12
* Set `rollup` and `eslint` as peer dependencies
* Generate TypeScript declaration files.

## 5.0.2 - 2018-11-02
* Update dependencies

## 5.0.1 - 2018-07-15
* Fix for case when fix doesn't produce output
* Fixes for ESLint 5.x
* Disable tests for source mapping. For some reason rollup returns the same 'mappings' for fixed and not fixed code even though the plugin produces different source maps
* Update dependencies

## 5.0.0 - 2018-01-21
* Rewrite to verify and fix the bundle instead of imported files
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# rollup-plugin-eslint-bundle ![build](https://github.com/nikolay-borzov/rollup-plugin-eslint-bundle/workflows/CI/badge.svg) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

[rollup]: https://github.com/rollup/rollup
[eslint-config]: https://eslint.org/docs/developer-guide/nodejs-api#parameters

[Rollup] plugin to lint (and fix) bundled code with ESLint.


## Install

```sh
npm i rollup-plugin-eslint-bundle -D
```

## Usage

```js
import { rollup } from 'rollup';
import { eslintBundle } from 'rollup-plugin-eslint-bundle';

rollup({
entry: 'main.js',
plugins: [
eslintBundle({
eslintOptions: {
fix: true
},
throwOnWarning: true,
throwOnError: true,
formatter: 'compact'
})
]
});
```

## Options

### `eslintOptions`

[ESLint class options object](https://eslint.org/docs/developer-guide/nodejs-api#parameters).

### `throwOnWarning`

Type: `boolean`
Default: `false`

If true, will throw an error if any warnings were found.

### `throwOnError`

Type: `boolean`
Default: `false`

If true, will throw an error if any errors were found.

### `formatter`

Type: `string`

[Value](https://eslint.org/docs/developer-guide/nodejs-api#-eslintloadformatternameorpath) to be passed to `eslint.loadFormatter()`

## License

MIT License (MIT)

## Contributing

If you find a bug or think about enhancement, feel free to contribute and submit an issue or a pull request.
19 changes: 19 additions & 0 deletions integration/rollup.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require('path')
const { eslintBundle } = require('../dist')

module.exports = {
input: path.resolve(__dirname, './src.js'),

output: {
file: path.resolve(__dirname, './dist/bundle.js'),
format: 'es',
sourcemap: true,
plugins: [
eslintBundle({
eslintOptions: {
fix: true,
},
}),
],
},
};
9 changes: 9 additions & 0 deletions integration/src.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function() {
var a = 6
if (!!foo) {
debugger;
return [a]
} else {
if(window) { return [1984, ]; }
}
}
10 changes: 10 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"moduleResolution": "node",
"resolveJsonModule": true,
"checkJs": true,
"strict": true
},
"include": ["src", "tests"],
"exclude": ["tests/fixtures"]
}
Loading

0 comments on commit 28362e1

Please sign in to comment.