forked from prisma/prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix precommit hooks (prisma#4316)
Co-authored-by: William Luke <william@ordino.ai>
- Loading branch information
1 parent
6bf3c0b
commit aa17fbc
Showing
144 changed files
with
4,053 additions
and
4,026 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
const globby = require('globby') | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const ignoreFiles = globby.sync('src/packages/*/.eslintignore') | ||
|
||
const ignorePatterns = flatten( | ||
flatten( | ||
ignoreFiles.map((f) => { | ||
const dir = path.dirname(f) | ||
return fs | ||
.readFileSync(f, 'utf-8') | ||
.split('\n') | ||
.filter((l) => l.trim().length > 0) | ||
.map((l) => [l, `/${path.join(dir, l)}`]) | ||
}), | ||
), | ||
) | ||
|
||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'jest'], | ||
env: { | ||
node: true, | ||
es6: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:eslint-comments/recommended', | ||
'plugin:jest/recommended', | ||
], | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: 'module', | ||
project: ['./src/packages/*/tsconfig.json' /* , 'tsconfig.json' */], | ||
// debugLevel: true, | ||
}, | ||
ignorePatterns, | ||
overrides: [ | ||
// { | ||
// files: ['*.js'], | ||
// rules: {}, | ||
// }, | ||
{ | ||
files: ['*.ts'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
'prettier/@typescript-eslint', | ||
'plugin:jest/recommended', | ||
], | ||
rules: { | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
'no-useless-escape': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/no-unsafe-return': 'off', | ||
// added at 2020/11/26 | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'eslint-comments/no-unlimited-disable': 'off', | ||
'eslint-comments/disable-enable-pair': 'off', | ||
'@typescript-eslint/no-misused-promises': 'off', | ||
'jest/expect-expect': 'off', | ||
'no-empty': 'off', | ||
'jest/valid-title': 'off', | ||
'@typescript-eslint/no-unnecessary-type-assertion': 'off', | ||
// low hanging fruits: | ||
'@typescript-eslint/ban-types': 'off', | ||
'@typescript-eslint/restrict-plus-operands': 'off', | ||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'jest/no-conditional-expect': 'off', | ||
'jest/no-try-expect': 'off', | ||
'jest/no-export': 'off', | ||
'@typescript-eslint/no-empty-interface': 'off', | ||
}, | ||
}, | ||
], | ||
settings: { | ||
jest: { | ||
version: 26, | ||
}, | ||
}, | ||
} | ||
|
||
function flatten(input) { | ||
const stack = [...input] | ||
const res = [] | ||
while (stack.length) { | ||
// pop value from stack | ||
const next = stack.pop() | ||
if (Array.isArray(next)) { | ||
// push back array items, won't modify the original input | ||
stack.push(...next) | ||
} else { | ||
res.push(next) | ||
} | ||
} | ||
// reverse to restore input order | ||
return res.reverse() | ||
} |
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
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 |
---|---|---|
|
@@ -20,3 +20,5 @@ dist/ | |
.vscode | ||
!.vscode/launch.json | ||
coverage | ||
|
||
.eslintcache |
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 |
---|---|---|
@@ -1,6 +1,32 @@ | ||
{ | ||
"dependencies": { | ||
"ts-node": "9.0.0", | ||
"typescript": "4.1.2" | ||
} | ||
"private": true, | ||
"scripts": { | ||
"lint": "ts-node scripts/lint.ts", | ||
"precommit-all": "ts-node scripts/lint.ts --staged", | ||
"eslint": "eslint" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.10", | ||
"@typescript-eslint/eslint-plugin": "^4.8.2", | ||
"@typescript-eslint/parser": "^4.8.2", | ||
"arg": "^5.0.0", | ||
"chalk": "^4.1.0", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-jest": "^24.1.3", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"execa": "^4.1.0", | ||
"globby": "^11.0.1", | ||
"husky": "^4.3.0", | ||
"p-map": "^4.0.0", | ||
"staged-git-files": "^1.2.0", | ||
"ts-node": "9.0.0", | ||
"typescript": "4.1.2" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "ts-node scripts/lint.ts --staged" | ||
} | ||
} | ||
} |
Oops, something went wrong.