Skip to content
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

fix: drop shell for lint #183

Merged
merged 2 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"ecmaVersion": 2020,
"sourceType": "module"
},
"extends": ["plugin:prettier/recommended"],
"env": {
"node": true
},
Expand Down
4 changes: 2 additions & 2 deletions config-overrides/SSRPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class SSRPlugin {
*/
const htmlWebpackPluginHook = HtmlWebpackPlugin.getHooks(compilation)
htmlWebpackPluginHook.beforeEmit.tapPromise('SSRPlugin', async args => {
let { html, outputName, plugin } = args
const { html: originalHTML, outputName, plugin } = args
if (outputName !== this.htmlFileName) return args
html = await this.generateSSRHTMLFile(compilation, html)
const html = await this.generateSSRHTMLFile(compilation, originalHTML)
return { html, outputName, plugin }
})
})
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
"@typescript-eslint/parser": "^2.0.0",
"awesome-typescript-loader": "^5.2.1",
"eslint": "^6.2.1",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-prettier": "^3.1.0",
"esm": "^3.2.25",
"prettier": "^1.18.2",
"react-devtools": "^3.6.1",
Expand Down
41 changes: 22 additions & 19 deletions scripts/lint.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
const { spawn } = require('./spawn')
const path = require('path')
const argv = require('yargs').argv

const base = path.join(__dirname, '../')
process.chdir(base)

const reportOnly = argv.reportOnly
const { CLIEngine } = require('eslint')

;(async () => {
!argv.noEslint
? await spawn('eslint', [
'--ignore-path',
'.prettierignore',
'--ext',
'tsx,ts,jsx,js',
...(argv._.length ? argv._ : ['./src/']),
...(reportOnly ? [] : ['--cache', '--fix']),
])
: null
!argv.noPrettier
? await spawn('prettier', [
...(argv._.length ? argv._ : ['./**/*.{ts,tsx,jsx,js}']),
...(reportOnly ? ['--check', '--loglevel', 'log'] : ['--write', '--loglevel', 'warn']),
])
: null
})()
const cli = new CLIEngine({
fix: !reportOnly,
cache: !reportOnly && !argv._.length,
extensions: ['.tsx', '.ts', '.jsx', '.js'],
})

const report = cli.executeOnFiles(argv._.length ? argv._ : ['.'])
if (!reportOnly) CLIEngine.outputFixes(report)

if (report.errorCount || report.warningCount) {
report.results
.filter(o => o.errorCount)
.forEach(o => {
return o.messages.forEach(m => {
;(m.severity === 2 ? console.error : console.warn)(
`At ${o.filePath}:${m.line}:${m.column} (${m.ruleId})\n\t${m.message}`,
)
})
})
if (report.errorCount) throw new Error('eslint found some error(s), please correct them.')
}
31 changes: 31 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6425,6 +6425,13 @@ escope@^3.6.0:
esrecurse "^4.1.0"
estraverse "^4.1.1"

eslint-config-prettier@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.3.0.tgz#e73b48e59dc49d950843f3eb96d519e2248286a3"
integrity sha512-EWaGjlDAZRzVFveh2Jsglcere2KK5CJBhkNSa1xs3KfMUGdRiT7lG089eqPdvlzWHpAqaekubOsOMu8W8Yk71A==
dependencies:
get-stdin "^6.0.0"

eslint-config-react-app@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-5.0.1.tgz#5f3d666ba3ee3cb384eb943e260e868f6c72251b"
Expand Down Expand Up @@ -6505,6 +6512,13 @@ [email protected]:
dependencies:
eslint "^3.7.1"

eslint-plugin-prettier@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz#8695188f95daa93b0dc54b249347ca3b79c4686d"
integrity sha512-XWX2yVuwVNLOUhQijAkXz+rMPPoCr7WFiAl8ig6I7Xn+pPVhDhzg4DxHpmbeb0iqjO9UronEA3Tb09ChnFVHHA==
dependencies:
prettier-linter-helpers "^1.0.0"

eslint-plugin-react-hooks@^1.6.1:
version "1.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04"
Expand Down Expand Up @@ -6995,6 +7009,11 @@ fast-deep-equal@^2.0.1:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=

fast-diff@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==

fast-glob@^2.0.2:
version "2.2.7"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d"
Expand Down Expand Up @@ -7613,6 +7632,11 @@ get-stdin@^4.0.1:
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe"
integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=

get-stdin@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==

get-stream@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14"
Expand Down Expand Up @@ -12939,6 +12963,13 @@ prepend-http@^2.0.0:
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=

prettier-linter-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
dependencies:
fast-diff "^1.1.2"

prettier@^1.18.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
Expand Down