-
-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(repo): migrate @TrySound/rollup-plugin-eslint #575
Merged
Merged
Changes from 50 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
2174c68
Initial
TrySound d24b703
Add documentation
TrySound a57ebfd
Add npm files filter
TrySound 8d93f67
1.0.0
TrySound 6a43cde
Clear dist folder
TrySound 66a8b91
Fix documentation
TrySound a76dc51
1.0.1
TrySound fc48b9f
Fix build
TrySound f83b07c
1.0.2
TrySound beea4a5
Upgrade eslint
TrySound 8ab1689
2.0.0
TrySound 37a8ac8
Tidy up
TrySound 1a4f911
Return a name
TrySound 79aa74b
2.0.2
TrySound 52240a6
Upgrade to eslint 3
TrySound b46eba4
Add buble back
TrySound 5693a22
v3.0.0
TrySound 0a24a4e
Add lockfile
TrySound 23486ce
Move to jest
TrySound 61c0c1b
Build with babel
TrySound a1a0c2c
Upgrade dependencies
TrySound 3e60dae
Add throwOnError and throwOnWarnings options. Remove throwError option
TrySound e2d3dcb
4.0.0
TrySound 0a56873
Document config file usage
markbrouch b677da3
Update config file documentation
markbrouch 3af75bf
Merge pull request #21 from markbrouch/patch-1
TrySound 9a09d0b
Update README.md
TrySound 002102c
Remove node4 support and remove babel
TrySound f4a9aae
Add prettier
TrySound 9b7d10a
Change api to named export
TrySound 7ba0743
Upgrade eslint
TrySound 64659df
Clean up gitignore
TrySound 9f07aa8
5.0.0
TrySound 459bc20
Fix tests warning
TrySound e838619
PR for optional config string
bugs181 07d1b2c
Fixed bug where .eslintrc files were still being used
bugs181 6a7da9e
Merge pull request #26 from bugs181/master
TrySound 223d2f2
v5.1.0
TrySound 8ed450c
feat: options.fix can change files
237c7f5
feat: add test case
Shenfq 3ef74c4
Merge pull request #27 from Shenfq/feature/fix-source-code
TrySound 4a6aa9f
Upgrade dependencies and tests
TrySound f83bf3c
v6.0.0
TrySound b65047f
Fix travis
TrySound 389e74d
Upgrade to ESLint 6.0.0
onigoetz b672ef3
Merge pull request #28 from onigoetz/master
TrySound 8c5aba3
v7.0.0
TrySound f71ab79
Preparing move to rollup/plugins
atti187 04a794e
Merge remote-tracking branch 'rollup-plugin-eslint/master'
atti187 8b7bc58
feat(eslint): fixed https://github.com/TrySound/rollup-plugin-eslint/…
atti187 f88bf21
chore: update after review
shellscape 93a4ef2
Merge remote-tracking branch 'upstream/master'
shellscape 507b9d4
chore: lint readme
shellscape File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test/fixtures/ignored.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!/test/fixtures/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @rollup/plugin-eslint ChangeLog | ||
|
||
## v8.0.0 | ||
|
||
_2020-09-15_ | ||
|
||
- Moved into repo from https://github.com/TrySound/rollup-plugin-eslint, see https://github.com/TrySound/rollup-plugin-eslint/pull/38 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
[npm]: https://img.shields.io/npm/v/@rollup/plugin-alias | ||
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-alias | ||
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-alias | ||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-alias | ||
|
||
[![npm][npm]][npm-url] | ||
[![size][size]][size-url] | ||
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com) | ||
|
||
# @rollup/plugin-eslint | ||
|
||
🍣 A Rollup plugin to verify entry point and all imported files with ESLint. | ||
|
||
## Install | ||
|
||
Using npm: | ||
|
||
```console | ||
npm install @rollup/plugin-eslint --save-dev | ||
# or | ||
yarn add -D @rollup/plugin-eslint | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { rollup } from 'rollup'; | ||
import eslint from '@rollup/plugin-eslint'; | ||
|
||
export default { | ||
input: 'main.js', | ||
plugins: [ | ||
eslint({ | ||
/* your options */ | ||
}), | ||
], | ||
}; | ||
``` | ||
|
||
## Options | ||
|
||
See more options here [eslint-config]. | ||
|
||
You can also use eslint configuration in the form of a `.eslintrc.*` file in your project's root. It will be loaded automatically. | ||
|
||
### fix | ||
|
||
Type: `boolean` | ||
Default: `false` | ||
|
||
If true, will auto fix source code. | ||
|
||
### throwOnError | ||
|
||
Type: `boolean` | ||
Default: `false` | ||
|
||
If true, will throw an error if any errors were found. | ||
|
||
### throwOnWarning | ||
|
||
Type: `boolean` | ||
Default: `false` | ||
|
||
If true, will throw an error if any warnings were found. | ||
|
||
### include | ||
|
||
Type: `array` or `string` | ||
Default: `[]` | ||
|
||
A single file, or array of files, to include when linting. | ||
|
||
### exclude | ||
|
||
Type: `array` or `string` | ||
Default: `node_modules/**` | ||
|
||
A single file, or array of files, to exclude when linting. | ||
|
||
### formatter | ||
|
||
Type: `function` or `string` | ||
Default: `stylish` | ||
|
||
Custom error formatter or the name of a built-in formatter. | ||
|
||
## Meta | ||
|
||
[CONTRIBUTING](/.github/CONTRIBUTING.md) | ||
|
||
[LICENSE (MIT)](/LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"name": "@rollup/plugin-eslint", | ||
"version": "8.0.0", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"description": "Verify entry point and all imported files with ESLint", | ||
"license": "MIT", | ||
"repository": "rollup/plugins", | ||
"author": "Bogdan Chadkin <trysound@yandex.ru>", | ||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/eslint#readme", | ||
"bugs": "https://github.com/rollup/plugins/issues", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"engines": { | ||
"node": ">= 10.0.0" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c", | ||
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov", | ||
"ci:lint": "pnpm run build && pnpm run lint", | ||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", | ||
"ci:test": "pnpm run test -- --verbose", | ||
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package", | ||
"lint:docs": "prettier --single-quote --arrow-parens avoid --trailing-comma none --write README.md", | ||
"lint:js": "eslint --fix --cache src test types --ext .js,.ts", | ||
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package", | ||
"prebuild": "del-cli dist", | ||
"prepare": "pnpm run build", | ||
"prepublishOnly": "pnpm run lint && pnpm run test", | ||
"pretest": "pnpm run build", | ||
"test": "ava" | ||
}, | ||
"files": [ | ||
"dist", | ||
"types", | ||
"README.md", | ||
"LICENSE" | ||
], | ||
"keywords": [ | ||
"rollup", | ||
"plugin", | ||
"rollup-plugin", | ||
"eslint", | ||
"es2015", | ||
"es6", | ||
"lint" | ||
], | ||
"peerDependencies": { | ||
"rollup": "^1.20.0||^2.0.0" | ||
}, | ||
"dependencies": { | ||
"eslint": "^6.0.0", | ||
"rollup-pluginutils": "^2.7.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"@rollup/plugin-typescript": "5.0.2", | ||
"@types/eslint": "^7.2.2", | ||
"rollup": "^2.23.0" | ||
}, | ||
"types": "types/index.d.ts", | ||
"ava": { | ||
"babel": { | ||
"compileEnhancements": false | ||
}, | ||
"extensions": [ | ||
"ts" | ||
], | ||
"require": [ | ||
"ts-node/register" | ||
], | ||
"files": [ | ||
"!**/fixtures/**", | ||
"!**/helpers/**", | ||
"!**/recipes/**", | ||
"!**/types.ts" | ||
], | ||
"contributors": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably should not be a part of ava config |
||
"Mattias Ekstrand <mattias.ekstrand@gmail.com>" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import typescript from '@rollup/plugin-typescript'; | ||
|
||
import pkg from './package.json'; | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
external: [...Object.keys(pkg.dependencies), 'path'], | ||
output: [ | ||
{ file: pkg.main, format: 'cjs', exports: 'auto' }, | ||
{ file: pkg.module, format: 'es' } | ||
], | ||
plugins: [typescript({ sourceMap: false })] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import * as path from 'path'; | ||
|
||
import { Plugin } from 'rollup'; | ||
import { createFilter } from 'rollup-pluginutils'; | ||
import { CLIEngine } from 'eslint'; | ||
|
||
import { RollupEslintOptions } from '../types'; | ||
|
||
function normalizePath(id: string) { | ||
return path | ||
.relative(process.cwd(), id) | ||
.split(path.sep) | ||
.join('/'); | ||
} | ||
|
||
export default function eslint(options = {} as RollupEslintOptions): Plugin { | ||
if (typeof options === 'string') { | ||
const configFile = path.resolve(process.cwd(), options); | ||
// eslint-disable-next-line global-require, import/no-dynamic-require, no-param-reassign | ||
options = require(configFile); | ||
// Tell eslint not to look for configuration files. | ||
// eslint-disable-next-line no-param-reassign | ||
options.useEslintrc = false; | ||
} | ||
|
||
const cli = new CLIEngine(options); | ||
let formatter: CLIEngine.Formatter; | ||
|
||
switch (typeof options.formatter) { | ||
case 'string': | ||
formatter = cli.getFormatter(options.formatter); | ||
break; | ||
case 'function': | ||
({ formatter } = options); | ||
break; | ||
default: | ||
formatter = cli.getFormatter('stylish'); | ||
} | ||
|
||
const filter = createFilter(options.include, options.exclude || /node_modules/); | ||
|
||
return { | ||
name: 'eslint', | ||
|
||
// eslint-disable-next-line consistent-return | ||
transform(code, id) { | ||
const file = normalizePath(id); | ||
if (!filter(id) || cli.isPathIgnored(file)) { | ||
return null; | ||
} | ||
|
||
const report = cli.executeOnText(code, file); | ||
const hasWarnings = options.throwOnWarning && report.warningCount !== 0; | ||
const hasErrors = options.throwOnError && report.errorCount !== 0; | ||
|
||
if (options.fix && report) { | ||
CLIEngine.outputFixes(report); | ||
} | ||
|
||
if (report.warningCount === 0 && report.errorCount === 0) { | ||
return null; | ||
} | ||
|
||
const result = formatter(report.results); | ||
|
||
if (result) { | ||
// eslint-disable-next-line no-console | ||
console.log(result); | ||
} | ||
|
||
if (hasWarnings && hasErrors) { | ||
throw Error('Warnings or errors were found'); | ||
} | ||
|
||
if (hasWarnings) { | ||
throw Error('Warnings were found'); | ||
} | ||
|
||
if (hasErrors) { | ||
throw Error('Errors were found'); | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
root: true | ||
|
||
env: | ||
browser: true | ||
node: true | ||
|
||
rules: | ||
no-alert: 2 | ||
no-bitwise: 1 | ||
camelcase: 1 | ||
curly: 1 | ||
eqeqeq: 0 | ||
no-eq-null: 0 | ||
guard-for-in: 1 | ||
no-empty: 1 | ||
no-use-before-define: 0 | ||
object-curly-spacing: 0 | ||
no-obj-calls: 2 | ||
no-unused-vars: 0 | ||
new-cap: 1 | ||
no-shadow: 0 | ||
strict: 2 | ||
global-strict: 0 | ||
no-invalid-regexp: 2 | ||
comma-dangle: 2 | ||
no-undef: 1 | ||
no-new: 1 | ||
no-extra-semi: 1 | ||
no-debugger: 2 | ||
no-caller: 1 | ||
semi: 1 | ||
quotes: 0 | ||
no-unreachable: 2 | ||
eol-last: 0 | ||
|
||
parserOptions: | ||
ecmaVersion: 2015 | ||
sourceType: 'module' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
browser: true, | ||
node: true, | ||
}, | ||
ignorePatterns: process.env.NODE_ENV === 'test' ? ["ignored.js"] : ["**/*.js"], | ||
rules: { | ||
"no-alert": 2, | ||
"no-bitwise": 1, | ||
"camelcase": 1, | ||
"curly": 1, | ||
"eqeqeq": 0, | ||
"no-eq-null": 0, | ||
"guard-for-in": 1, | ||
"no-empty": 1, | ||
"no-use-before-define": 0, | ||
"object-curly-spacing": 0, | ||
"no-obj-calls": 2, | ||
"no-unused-vars": 0, | ||
"new-cap": 1, | ||
"no-shadow": 0, | ||
"strict": 2, | ||
"global-strict": 0, | ||
"no-invalid-regexp": 2, | ||
"comma-dangle": 2, | ||
"no-undef": 1, | ||
"no-new": 1, | ||
"no-extra-semi": 1, | ||
"no-debugger": 2, | ||
"no-caller": 1, | ||
"semi": 1, | ||
"quotes": 0, | ||
"no-unreachable": 2, | ||
"eol-last": 0, | ||
}, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd avoid mentioning 2020, let's skip straight to 2021