Skip to content

Commit 9a4d098

Browse files
authored
Merge pull request #25 from paleite/update-tooling
Update tooling
2 parents 48b2831 + e6f2102 commit 9a4d098

File tree

8 files changed

+35
-34
lines changed

8 files changed

+35
-34
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const typescriptProjects = ["./tsconfig.json", "./tsconfig.eslint.json"];
33
/** @type import("eslint").Linter.Config */
44
module.exports = {
55
root: true,
6-
extends: ["@paleite"],
6+
extends: ["@paleite", "plugin:diff/diff"],
77
parserOptions: { project: typescriptProjects, tsconfigRootDir: __dirname },
88
overrides: [
99
{

.github/workflows/eslint-plugin-diff.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ jobs:
88
- uses: actions/checkout@v3
99
- name: Install modules
1010
run: yarn
11+
- name: Link the plugin
12+
run: |
13+
yarn link
14+
yarn link "eslint-plugin-diff"
15+
- name: Fetch the base branch
16+
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
1117
- name: Run ESLint on your changes only
1218
env:
13-
ESLINT_PLUGIN_DIFF_COMMIT: $GITHUB_HEAD_REF
14-
run: eslint --ext .js,.jsx,.ts,.tsx .
19+
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
20+
run: npx --no-install eslint --ext .js,.jsx,.ts,.tsx .

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,23 @@ To lint all the changes of a PR, you only have to set
5454

5555
### For GitHub Actions
5656

57-
```sh
58-
export ESLINT_PLUGIN_DIFF_COMMIT="origin/$GITHUB_BASE_REF";
59-
npx --no-install eslint --ext .js,.ts,.tsx .
57+
```yml
58+
name: Run ESLint on your changes only
59+
on:
60+
pull_request:
61+
jobs:
62+
build:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v3
66+
- name: Install modules
67+
run: npm install
68+
- name: Fetch the base branch
69+
run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }}
70+
- name: Run ESLint on your changes only
71+
env:
72+
ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }}
73+
run: npx --no-install eslint --ext .js,.jsx,.ts,.tsx .
6074
```
6175
6276
### For BitBucket Pipelines

lint-staged.config.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
const { eslintFiles } = require("eslint-files");
2-
31
module.exports = {
4-
"*.{html,json,md,yaml,yml}": ["prettier --write"],
5-
"*.{js,ts}": [
6-
() => "yarn run typecheck",
7-
"jest --bail --findRelatedTests --passWithNoTests",
8-
/**
9-
* @param {string[]} files
10-
*/
11-
async (files) =>
12-
`eslint --fix --max-warnings=0 ${await eslintFiles(files)}`,
13-
"prettier --write",
14-
],
2+
"*.ts": [() => "yarn run typecheck"],
153
};

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
"build": "tsc --build tsconfig.build.json",
3131
"clean": "tsc --build tsconfig.build.json --clean",
3232
"format": "prettier --write .",
33-
"postinstall": "husky install",
3433
"lint": "eslint --cache --ext .js,.ts --fix .",
34+
"minify": "find dist/ -maxdepth 1 -iname '*.js' -exec node_modules/.bin/terser --compress --ecma 2020 --mangle --module --output {} -- {} \\;",
35+
"prepare": "husky install",
3536
"prepublishOnly": "pinst --disable",
3637
"prepublish": "yarn run clean && yarn run build && yarn run minify",
3738
"postpublish": "pinst --enable",
3839
"release": "np",
3940
"size": "size-limit",
4041
"test": "jest --coverage",
41-
"typecheck": "tsc --project tsconfig.json",
42-
"minify": "find dist/ -maxdepth 1 -iname '*.js' -exec node_modules/.bin/terser --compress --ecma 2020 --mangle --module --output {} -- {} \\;"
42+
"typecheck": "tsc --project tsconfig.json --noEmit"
4343
},
4444
"devDependencies": {
4545
"@paleite/eslint-config": "^1.0.2",
@@ -56,7 +56,6 @@
5656
"@typescript-eslint/parser": "^5.27.0",
5757
"eslint": "^8.17.0",
5858
"eslint-config-prettier": "^8.5.0",
59-
"eslint-files": "^1.0.0",
6059
"eslint-plugin-import": "^2.26.0",
6160
"eslint-plugin-promise": "^6.0.0",
6261
"husky": "^8.0.1",

src/git.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const getDiffForFile = (filePath: string, staged = false): string => {
2222
[]
2323
);
2424

25-
return child_process.execFileSync(COMMAND, args).toString();
25+
return child_process.execFileSync(COMMAND, args, options).toString();
2626
};
2727

2828
const getDiffFileList = (staged = false): string[] => {
@@ -42,7 +42,7 @@ const getDiffFileList = (staged = false): string[] => {
4242
);
4343

4444
return child_process
45-
.execFileSync(COMMAND, args)
45+
.execFileSync(COMMAND, args, options)
4646
.toString()
4747
.trim()
4848
.split("\n")
@@ -62,14 +62,15 @@ const hasCleanIndex = (filePath: string): boolean => {
6262

6363
let result = true;
6464
try {
65-
child_process.execFileSync(COMMAND, args).toString();
65+
child_process.execFileSync(COMMAND, args, options).toString();
6666
} catch (err: unknown) {
6767
result = false;
6868
}
6969

7070
return result;
7171
};
7272

73+
const options = { maxBuffer: 1024 * 1024 * 100 };
7374
const getUntrackedFileList = (staged = false): string[] => {
7475
if (staged) {
7576
return [];
@@ -78,7 +79,7 @@ const getUntrackedFileList = (staged = false): string[] => {
7879
const args = ["ls-files", "--exclude-standard", "--others"];
7980

8081
const untrackedFileListCache = child_process
81-
.execFileSync(COMMAND, args)
82+
.execFileSync(COMMAND, args, options)
8283
.toString()
8384
.trim()
8485
.split("\n")

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"extends": "./tsconfig.build.json",
33
"compilerOptions": {
4-
"composite": false,
5-
"noEmit": true,
64
"rootDir": "."
75
},
86

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,11 +1875,6 @@ eslint-config-prettier@^8.5.0:
18751875
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1"
18761876
integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==
18771877

1878-
eslint-files@^1.0.0:
1879-
version "1.0.0"
1880-
resolved "https://registry.yarnpkg.com/eslint-files/-/eslint-files-1.0.0.tgz#82a1afcc4b2ab5ae7c6b9b472bd2d1ebc7be2e58"
1881-
integrity sha512-nwNfDKR7+R9X/ZXQLVqsaIVTVre/59Yg+M2eOoBS6E/qaz0fWYugrX3XT2j1C288ImRc2SeFvyIm7uyaLq8AHg==
1882-
18831878
eslint-import-resolver-node@^0.3.6:
18841879
version "0.3.6"
18851880
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd"

0 commit comments

Comments
 (0)