Skip to content

Commit aa17fbc

Browse files
timsuchanekWilliam Luke
and
William Luke
authored
chore: fix precommit hooks (prisma#4316)
Co-authored-by: William Luke <william@ordino.ai>
1 parent 6bf3c0b commit aa17fbc

File tree

144 files changed

+4053
-4026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+4053
-4026
lines changed

.eslintrc.js

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
const globby = require('globby')
2+
const fs = require('fs')
3+
const path = require('path')
4+
5+
const ignoreFiles = globby.sync('src/packages/*/.eslintignore')
6+
7+
const ignorePatterns = flatten(
8+
flatten(
9+
ignoreFiles.map((f) => {
10+
const dir = path.dirname(f)
11+
return fs
12+
.readFileSync(f, 'utf-8')
13+
.split('\n')
14+
.filter((l) => l.trim().length > 0)
15+
.map((l) => [l, `/${path.join(dir, l)}`])
16+
}),
17+
),
18+
)
19+
20+
module.exports = {
21+
root: true,
22+
parser: '@typescript-eslint/parser',
23+
plugins: ['@typescript-eslint', 'jest'],
24+
env: {
25+
node: true,
26+
es6: true,
27+
},
28+
extends: [
29+
'eslint:recommended',
30+
'plugin:eslint-comments/recommended',
31+
'plugin:jest/recommended',
32+
],
33+
parserOptions: {
34+
ecmaVersion: 2020,
35+
sourceType: 'module',
36+
project: ['./src/packages/*/tsconfig.json' /* , 'tsconfig.json' */],
37+
// debugLevel: true,
38+
},
39+
ignorePatterns,
40+
overrides: [
41+
// {
42+
// files: ['*.js'],
43+
// rules: {},
44+
// },
45+
{
46+
files: ['*.ts'],
47+
extends: [
48+
'eslint:recommended',
49+
'plugin:@typescript-eslint/eslint-recommended',
50+
'plugin:@typescript-eslint/recommended',
51+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
52+
'prettier/@typescript-eslint',
53+
'plugin:jest/recommended',
54+
],
55+
rules: {
56+
'@typescript-eslint/no-use-before-define': 'off',
57+
'@typescript-eslint/no-non-null-assertion': 'off',
58+
'no-useless-escape': 'off',
59+
'@typescript-eslint/no-explicit-any': 'off',
60+
'@typescript-eslint/no-var-requires': 'off',
61+
'@typescript-eslint/no-unsafe-return': 'off',
62+
// added at 2020/11/26
63+
'@typescript-eslint/no-unsafe-call': 'off',
64+
'@typescript-eslint/no-unsafe-member-access': 'off',
65+
'@typescript-eslint/no-unsafe-assignment': 'off',
66+
'@typescript-eslint/explicit-module-boundary-types': 'off',
67+
'@typescript-eslint/ban-ts-comment': 'off',
68+
'@typescript-eslint/no-empty-function': 'off',
69+
'eslint-comments/no-unlimited-disable': 'off',
70+
'eslint-comments/disable-enable-pair': 'off',
71+
'@typescript-eslint/no-misused-promises': 'off',
72+
'jest/expect-expect': 'off',
73+
'no-empty': 'off',
74+
'jest/valid-title': 'off',
75+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
76+
// low hanging fruits:
77+
'@typescript-eslint/ban-types': 'off',
78+
'@typescript-eslint/restrict-plus-operands': 'off',
79+
'@typescript-eslint/restrict-template-expressions': 'off',
80+
'jest/no-conditional-expect': 'off',
81+
'jest/no-try-expect': 'off',
82+
'jest/no-export': 'off',
83+
'@typescript-eslint/no-empty-interface': 'off',
84+
},
85+
},
86+
],
87+
settings: {
88+
jest: {
89+
version: 26,
90+
},
91+
},
92+
}
93+
94+
function flatten(input) {
95+
const stack = [...input]
96+
const res = []
97+
while (stack.length) {
98+
// pop value from stack
99+
const next = stack.pop()
100+
if (Array.isArray(next)) {
101+
// push back array items, won't modify the original input
102+
stack.push(...next)
103+
} else {
104+
res.push(next)
105+
}
106+
}
107+
// reverse to restore input order
108+
return res.reverse()
109+
}

.github/workflows/setup.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
set -ex
44

5+
npm i --silent -g pnpm@5.10.4 --unsafe-perm
6+
7+
pnpm i --no-prefer-frozen-lockfile
58
cd src
69

7-
npm i --silent -g pnpm@5.10.4 --unsafe-perm
810
pnpm i --no-prefer-frozen-lockfile
911

1012
pnpm run setup

.github/workflows/test.yml

+42
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,48 @@ jobs:
3232
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3333
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
3434

35+
#
36+
# Linting
37+
#
38+
lint:
39+
timeout-minutes: 5
40+
runs-on: ubuntu-latest
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
os: [ubuntu-latest]
46+
node: [12]
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
# From https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
52+
- name: Cache node modules
53+
uses: actions/cache@v2
54+
env:
55+
cache-name: cache-node-modules
56+
with:
57+
path: ~/.pnpm-store
58+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
59+
restore-keys: |
60+
${{ runner.os }}-build-${{ env.cache-name }}-
61+
${{ runner.os }}-build-
62+
${{ runner.os }}-
63+
64+
- uses: actions/setup-node@v2-beta
65+
with:
66+
node-version: ${{ matrix.node }}
67+
68+
- run: bash .github/workflows/setup.sh
69+
env:
70+
CI: true
71+
SKIP_GIT: true
72+
GITHUB_CONTEXT: ${{ toJson(github) }}
73+
74+
- run: pnpm run lint
75+
working-directory: ./
76+
3577
#
3678
# CLI-INTEGRATION-1
3779
#

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ dist/
2020
.vscode
2121
!.vscode/launch.json
2222
coverage
23+
24+
.eslintcache

package.json

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
{
2-
"dependencies": {
3-
"ts-node": "9.0.0",
4-
"typescript": "4.1.2"
5-
}
2+
"private": true,
3+
"scripts": {
4+
"lint": "ts-node scripts/lint.ts",
5+
"precommit-all": "ts-node scripts/lint.ts --staged",
6+
"eslint": "eslint"
7+
},
8+
"devDependencies": {
9+
"@types/node": "^14.14.10",
10+
"@typescript-eslint/eslint-plugin": "^4.8.2",
11+
"@typescript-eslint/parser": "^4.8.2",
12+
"arg": "^5.0.0",
13+
"chalk": "^4.1.0",
14+
"eslint": "^7.14.0",
15+
"eslint-config-prettier": "^6.15.0",
16+
"eslint-plugin-eslint-comments": "^3.2.0",
17+
"eslint-plugin-jest": "^24.1.3",
18+
"eslint-plugin-prettier": "^3.1.4",
19+
"execa": "^4.1.0",
20+
"globby": "^11.0.1",
21+
"husky": "^4.3.0",
22+
"p-map": "^4.0.0",
23+
"staged-git-files": "^1.2.0",
24+
"ts-node": "9.0.0",
25+
"typescript": "4.1.2"
26+
},
27+
"husky": {
28+
"hooks": {
29+
"pre-commit": "ts-node scripts/lint.ts --staged"
30+
}
31+
}
632
}

0 commit comments

Comments
 (0)