Skip to content

Commit

Permalink
feat(eslint): add eslint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepolischuk committed Mar 27, 2024
1 parent e81df8c commit 6770776
Show file tree
Hide file tree
Showing 5 changed files with 382 additions and 22 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Addons for [Razzle](https://github.com/jaredpalmer/razzle)
## Tools

* [Bundle Analyzer](packages/bundle-analyzer)
* [Chunks](packages/chunks)
* [Compression](packages/compression)
* [CSS](packages/css)
* [Environment](packages/environment)
* [ESLint](packages/eslint)
* [Multi Entry](packages/multi-entry)
* [SVGR](packages/svgr)

Expand Down
33 changes: 33 additions & 0 deletions packages/eslint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ESLint Plugin

Find problems in your code on build step

## Install

```
npm install -D @rambler-tech/razzle-eslint eslint
```

or

```
yarn add -D @rambler-tech/razzle-eslint eslint
```

## Usage

Add the plugin to `razzle.config.js`

```js
const ESLintPlugin = require('@rambler-tech/razzle-eslint')

module.exports = {
plugins: [
ESLintPlugin(),
],
modifyWebpackConfig({webpackConfig}) {
// ...
return webpackConfig
}
}
```
16 changes: 16 additions & 0 deletions packages/eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const ESLintPlugin = require('eslint-webpack-plugin')
const formatter = require('react-dev-utils/eslintFormatter')

module.exports = (options = {}) => ({
modifyWebpackConfig({webpackConfig}) {
webpackConfig.plugins = [
new ESLintPlugin({
...options,
formatter
}),
...webpackConfig.plugins
]

return webpackConfig
}
})
19 changes: 19 additions & 0 deletions packages/eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@rambler-tech/razzle-eslint",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"dependencies": {
"eslint-webpack-plugin": "^4.1.0",
"react-dev-utils": "^12.0.1"
},
"peerDependencies": {
"razzle": ">=4",
"webpack": ">=5",
"eslint": ">=8"
}
}
Loading

0 comments on commit 6770776

Please sign in to comment.