Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

55 changes: 0 additions & 55 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/run-lint-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -29,7 +29,7 @@ jobs:
- run: git config --global user.email "backportci@users.noreply.github.com "
- run: git config --global user.name "Backport CI"
- run: yarn
- run: yarn build
- run: yarn lint
- run: yarn tsc
- run: yarn test
- run: ACCESS_TOKEN=${{ secrets.GH_ACCESS_TOKEN }} yarn test-private
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/yarn-error.log
.DS_Store
/.env
/src/graphql
/.eslintcache
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
3 changes: 0 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint
2 changes: 0 additions & 2 deletions .istanbul.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.*
v22.*
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"github-schema.graphql": true,
"LICENSE.txt": true
},
"editor.formatOnSave": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"files.associations": {
"*.yaml": "home-assistant"
}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn start --branch 6.1 --repo backport-org/backport-demo --all
This will build backport continously and link it, so it can accessed with `backport` command globally

```
yarn tsc && sudo chmod +x bin/backport && yarn unlink; yarn link && yarn tsc --watch
yarn build && chmod +x bin/backport && yarn unlink; yarn link && yarn tsc --watch
```

**Remove linked backport**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The remaining documentation focuses on the Backport CLI tool (not the Github Act

## Requirements

- Node 18 or higher
- Node 22 or higher
- git

## Install
Expand Down
2 changes: 1 addition & 1 deletion bin/backport
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('../dist/entrypoint.cli.js')
require('../dist/src/entrypoint.cli.js')
29 changes: 29 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { CodegenConfig } from '@graphql-codegen/cli';

const config: CodegenConfig = {
overwrite: true,
schema: './schema.graphql',
documents: ['src/**/*.ts'],

ignoreNoDocuments: true,

generates: {
'src/graphql/generated/': {
preset: 'client-preset',
presetConfig: {
gqlTagName: 'graphql',
fragmentMasking: false,
},
config: {
skipTypename: false, // Include __typename
withHooks: false, // Disable React hooks
urqlImportFrom: '@urql/core',
},
},
},
hooks: {
afterAllFileWrite: ['prettier --write'],
},
};

export default config;
2 changes: 1 addition & 1 deletion docs/cli-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The CLI options will override the [config-file-options.md](/docs/config-file-opt
| --reviewer | | Add reviewer to the target PR | |
| --sha | | Sha of commit to backport | |
| --signoff | -s | Pass the --signoff option to the cherry-pick command | false |
| --copySourcePRLabels | | Copy labels from source PR to the target PR | false |
| --copySourcePRLabels | | Copy labels from source PR to the target PR (regex support via config) | false |
| --copySourcePRReviewers | | Copy reviewers from source PR to the target PR | false |
| --backportBranchName | | Name template to use for the branch name of the backport | |
| --source-branch | | Specify a non-default branch to backport from | |
Expand Down
10 changes: 8 additions & 2 deletions docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,17 @@ Assign the same reviewers to the target pull request that were assigned to the o

#### `copySourcePRLabels`

Copies all labels from the original (source) pull request to the backport (target) pull request.
Copy labels from the original (source) pull request to the backport (target) pull request. When set to `true`, every non-backport label is copied. To copy only specific labels, provide one or more regular expressions; labels that match at least one pattern will be copied. (default: `false`)

```json
{
"copySourcePRLabels": false
"copySourcePRLabels": true
}
```

```json
{
"copySourcePRLabels": ["^version-\\d+$", "^release_note:\\w+$"]
}
```

Expand Down
141 changes: 141 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
const js = require('@eslint/js');
const tseslint = require('@typescript-eslint/eslint-plugin');
const tsparser = require('@typescript-eslint/parser');
const importPlugin = require('eslint-plugin-import');

const nodeGlobals = {
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
global: 'readonly',
console: 'readonly',
fetch: 'readonly',
Headers: 'readonly',
Request: 'readonly',
Response: 'readonly',
NodeJS: 'readonly',
};

module.exports = [
// Global ignores
{
ignores: [
'dist/**',
'node_modules/**',
'src/graphql/generated/**',
'bin/**',
'coverage/**',
],
},

// Config files (CommonJS)
{
files: ['*.config.js', '.*.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
globals: {
require: 'readonly',
module: 'readonly',
exports: 'readonly',
...nodeGlobals,
},
},
...js.configs.recommended,
},

// JavaScript files
{
files: ['**/*.js'],
ignores: ['*.config.js', '.*.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: nodeGlobals,
},
...js.configs.recommended,
},

// TypeScript files
{
files: ['**/*.ts'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parser: tsparser,
parserOptions: {
project: './tsconfig.eslint.json',
},
globals: nodeGlobals,
},
plugins: {
'@typescript-eslint': tseslint,
import: importPlugin,
},
rules: {
...js.configs.recommended.rules,
...tseslint.configs.recommended.rules,

// Import organization
'import/order': [
'error',
{
alphabetize: { order: 'asc' },
'newlines-between': 'never',
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
},
],
'import/no-duplicates': 'error',

// Essential TypeScript rules
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-floating-promises': 'error',

// Turn off base rule in favor of TypeScript version
'no-unused-vars': 'off',
},
},

// Test files - relaxed rules and Jest globals
{
files: ['**/*.{test,spec}.{js,ts}', '**/test/**/*.{js,ts}'],
languageOptions: {
parser: tsparser,
parserOptions: {
project: './tsconfig.eslint.json',
},
globals: {
...nodeGlobals,
describe: 'readonly',
it: 'readonly',
test: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
jest: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
},
rules: {
...js.configs.recommended.rules,
...tseslint.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
},
},
];
2 changes: 0 additions & 2 deletions jest.config.all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import baseConfig from './jest.config';

const config = {
...baseConfig,

modulePathIgnorePatterns: [],
testSequencer: './jest.testSequencer.js',
};

export default config;
11 changes: 10 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ const baseConfig: JestConfigWithTsJest = {
},
snapshotSerializers: ['jest-snapshot-serializer-ansi'],
setupFiles: ['./src/test/setupFiles/automatic-mocks.ts'],
setupFilesAfterEnv: ['./src/test/setupFiles/setup-after-env.ts'],
setupFilesAfterEnv: [
'./src/test/setupFiles/jest-retry.ts',
'./src/test/setupFiles/nock-cleanup.ts',
],
preset: 'ts-jest',
testRegex: 'src/.*test.ts$',
testEnvironment: 'node',

// Configure memory management for Jest 30
workerIdleMemoryLimit: '512MB',

// Jest 30 compatibility settings - less aggressive cleanup to preserve mocks
clearMocks: true,

// exclude "private" tests that requires credentials and can therefore not run on CI for external contributors
// exclude "mutation" tests that cannot run on in parallel (like they are on CI) because they mutate shared state
modulePathIgnorePatterns: ['.*.private.test.ts$', '.*.mutation.test.ts$'],
Expand Down
Loading
Loading