diff --git a/.github/workflows/ci-pull-requests.yml b/.github/workflows/ci-pull-requests.yml index 95e0d6f859..3be4f949fa 100644 --- a/.github/workflows/ci-pull-requests.yml +++ b/.github/workflows/ci-pull-requests.yml @@ -13,18 +13,27 @@ jobs: node-version: [14.x, 16.x] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: 'npm' - - name: npm install, build, and test - run: | - npm install -g npm@latest - npm install - npm run build --if-present - npm test - npm run lint + + - name: Install npm and dependencies + run: npm install -g npm@latest && npm install + + - name: Build + run: npm run build --if-present + + - name: Test + run: npm run test + + - name: Fetch base branch for `git diff` + run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} + + - name: Run ESLint on changes only env: - CI: true + ESLINT_PLUGIN_DIFF_COMMIT: ${{ github.event.pull_request.base.ref }} + run: npm run lint diff --git a/package-lock.json b/package-lock.json index 3d91b3938d..3bad542797 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21790,6 +21790,18 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-diff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-diff/-/eslint-plugin-diff-2.0.1.tgz", + "integrity": "sha512-qqbvwaaO1cfkUprliqiRojRsD0qGsvzmJNqNrb9s0h15sDVzZMXYdu0TUFpUwauLeU28etSsfWIp0Uu+OAcXXw==", + "dev": true, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "eslint": ">=6.7.0" + } + }, "node_modules/eslint-plugin-import": { "version": "2.26.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", @@ -52138,6 +52150,7 @@ "eslint": "8.23.0", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "^8.5.0", + "eslint-plugin-diff": "^2.0.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.4.0" @@ -55958,6 +55971,7 @@ "eslint": "8.23.0", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "^8.5.0", + "eslint-plugin-diff": "^2.0.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.4.0" @@ -70014,6 +70028,12 @@ } } }, + "eslint-plugin-diff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-diff/-/eslint-plugin-diff-2.0.1.tgz", + "integrity": "sha512-qqbvwaaO1cfkUprliqiRojRsD0qGsvzmJNqNrb9s0h15sDVzZMXYdu0TUFpUwauLeU28etSsfWIp0Uu+OAcXXw==", + "dev": true + }, "eslint-plugin-import": { "version": "2.26.0", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", diff --git a/packages/@n8n_io/eslint-config/base.js b/packages/@n8n_io/eslint-config/base.js index 314b3f33a8..260db7a1fc 100644 --- a/packages/@n8n_io/eslint-config/base.js +++ b/packages/@n8n_io/eslint-config/base.js @@ -33,6 +33,13 @@ module.exports = { * https://github.com/prettier/eslint-plugin-prettier */ 'eslint-plugin-prettier', + + /** + * Plugin to lint only changes + * + * https://github.com/paleite/eslint-plugin-diff#plugindiffdiff-recommended + */ + 'eslint-plugin-diff', ], extends: [ @@ -64,6 +71,13 @@ module.exports = { * https://github.com/prettier/eslint-config-prettier */ 'eslint-config-prettier', + + /** + * Config for eslint-plugin-diff + * + * https://github.com/paleite/eslint-plugin-diff#plugindiffdiff-recommended + */ + 'plugin:diff/diff', ], rules: { @@ -180,10 +194,7 @@ module.exports = { /** * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md */ - '@typescript-eslint/explicit-member-accessibility': [ - 'error', - { accessibility: 'no-public' }, - ], + '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }], /** * https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md diff --git a/packages/@n8n_io/eslint-config/package.json b/packages/@n8n_io/eslint-config/package.json index 0591ad91e6..44f618b50c 100644 --- a/packages/@n8n_io/eslint-config/package.json +++ b/packages/@n8n_io/eslint-config/package.json @@ -9,6 +9,7 @@ "eslint": "8.23.0", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-config-prettier": "^8.5.0", + "eslint-plugin-diff": "^2.0.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.4.0"