Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
generated_code = true

[/internal/events/**/*.schema.json]
insert_final_newline = unset
92 changes: 92 additions & 0 deletions .github/workflows/stage-1-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,95 @@ jobs:
idp_aws_report_upload_region: "${{ secrets.IDP_AWS_REPORT_UPLOAD_REGION }}"
idp_aws_report_upload_role_name: "${{ secrets.IDP_AWS_REPORT_UPLOAD_ROLE_NAME }}"
idp_aws_report_upload_bucket_endpoint: "${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}"

detect-event-schema-package-changes:
name: "Check for changes to event schema package compared to main branch"
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
changed: ${{ steps.check.outputs.changed }}
main_version: ${{ steps.check.outputs.main_version }}

steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Detect package changes and current version
id: check
run: |
git fetch origin main

if git diff --quiet origin/main...HEAD -- internal/events; then
echo "No changes in event schemas package"
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in event schemas"
echo "changed=true" >> $GITHUB_OUTPUT
fi

if content=$(git show origin/main:internal/events/schemas/package.json 2>/dev/null); then
version=$(jq -r .version <<< $content);
else
version=null;
fi

echo "Detected package version $version in main branch"
echo "main_version=$version" >> $GITHUB_OUTPUT

check-schemas-generated:
name: Check event schemas have been regenerated
needs: detect-event-schema-package-changes
if: needs.detect-event-schema-package-changes.outputs.changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Checkout code"
uses: actions/checkout@v4

# Simplified caching - template management has more complex caching of installed modules from another build step
- name: "Cache node_modules"
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ inputs.nodejs_version }}-

- name: "Re-generate schemas"
run: |
npm ci --workspace internal/events
npm --workspace internal/events run gen:jsonschema

- name: Check for schema changes
run: git diff --quiet internal/events/schemas

check-schema-version-change:
name: Check event schema version has been updated
needs: detect-event-schema-package-changes
if: needs.detect-event-schema-package-changes.outputs.changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check schema versions
run: |
source scripts/is_valid_increment.sh

main_version="${{ needs.detect-event-schema-package-changes.outputs.main_version }}"
echo "Main version: ${{ needs.detect-event-schema-package-changes.outputs.main_version }}"

local_version=$(jq -r '.version' internal/events/package.json)
echo "Local version: $local_version"

if ! is_valid_increment "$main_version" "$local_version" ; then
echo "Error: Event Schema package has changed, but new version ($local_version) is not a valid increment from latest version on main branch ($main_version)."
exit 1
fi
142 changes: 56 additions & 86 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import unicorn from 'eslint-plugin-unicorn';
import { defineConfig, globalIgnores } from 'eslint/config';
import js from '@eslint/js';
import html from 'eslint-plugin-html';
import tseslint from '@typescript-eslint/parser';
import tseslint from 'typescript-eslint'; // Replace plugin-only import with meta package that includes configs
import sortDestructureKeys from 'eslint-plugin-sort-destructure-keys';
import {
configs as airbnbConfigs,
Expand Down Expand Up @@ -40,9 +40,15 @@ export default defineConfig([
'**/test-results',
'**/playwright-report*',
'eslint.config.mjs',
// newly ignored generated/build artifacts
'build/**',
'sdk/**',
'docs/_site/**',
'docs/vendor/**',
'docs/**/*.html',
]),

//imports
// imports
importX.flatConfigs.recommended,
{ rules: { ...airbnbPlugins.importX.rules } },

Expand All @@ -66,21 +72,16 @@ export default defineConfig([
},
},
},

{
files: ['**/*.json'],
extends: [tseslint.configs.disableTypeChecked],
},
{ files: ['**/*.json'], extends: [tseslint.configs.disableTypeChecked] },

{
settings: {
'import-x/resolver-next': [
eslintImportResolverTypescript.createTypeScriptImportResolver({
project: [
'frontend/tsconfig.json',
'lambdas/*/tsconfig.json',
'tests/test-team/tsconfig.json',
'utils/*/tsconfig.json',
'internal/*/tsconfig.json',
],
}),
],
Expand All @@ -91,10 +92,7 @@ export default defineConfig([
rules: {
'@typescript-eslint/no-unused-vars': [
2,
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-definitions': 0,
},
Expand All @@ -107,22 +105,13 @@ export default defineConfig([
'unicorn/prevent-abbreviations': 0,
'unicorn/filename-case': [
2,
{
case: 'kebabCase',
ignore: ['.tsx'],
},
{ case: 'kebabCase', ignore: ['.tsx'] },
],
'unicorn/no-null': 0,
'unicorn/prefer-module': 0,
'unicorn/import-style': [
2,
{
styles: {
path: {
named: true,
},
},
},
{ styles: { path: { named: true } } },
],
},
},
Expand All @@ -145,103 +134,54 @@ export default defineConfig([
// jsxA11y
{
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
plugins: {
'jsx-a11y': jsxA11y,
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: { 'jsx-a11y': jsxA11y },
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
},

// security
security.configs.recommended,

// sonar
sonarjs.configs.recommended,

// html
{
files: ['**/*.html'],
plugins: { html },
},

// Next.js
...compat.config({
extends: ['next', 'next/core-web-vitals', 'next/typescript'],
settings: {
next: {
rootDir: 'frontend',
},
},
rules: {
// needed because next lint rules look for a pages directory
'@next/next/no-html-link-for-pages': 0,
},
}),
{ files: ['**/*.html'], plugins: { html } },

// json
{
files: ['**/*.json'],
...json.configs['recommended'],
},
{ files: ['**/*.json'], ...json.configs['recommended'] },

// destructure sorting
{
name: 'eslint-plugin-sort-destructure-keys',
plugins: {
'sort-destructure-keys': sortDestructureKeys,
},
rules: {
'sort-destructure-keys/sort-destructure-keys': 2,
},
plugins: { 'sort-destructure-keys': sortDestructureKeys },
rules: { 'sort-destructure-keys/sort-destructure-keys': 2 },
},

// imports
{
rules: {
'sort-imports': [
2,
{
ignoreDeclarationSort: true,
},
],
'sort-imports': [2, { ignoreDeclarationSort: true }],
'import-x/extensions': 0,
},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {
'import-x/no-unresolved': 0, // trust the typescript compiler to catch unresolved imports
},
rules: { 'import-x/no-unresolved': 0 },
},
{
files: ['tests/test-team/**'],
rules: {
'import-x/no-extraneous-dependencies': [
2,
{
devDependencies: true,
},
{ devDependencies: true },
],
},
},
{
files: ['**/utils/**', 'tests/test-team/**'],
rules: {
'import-x/prefer-default-export': 0,
},
rules: { 'import-x/prefer-default-export': 0 },
},
{
plugins: {
'no-relative-import-paths': noRelativeImportPaths,
},
rules: {
'no-relative-import-paths/no-relative-import-paths': 2,
},
plugins: { 'no-relative-import-paths': noRelativeImportPaths },
rules: { 'no-relative-import-paths/no-relative-import-paths': 2 },
},
{
files: ['scripts/**'],
Expand All @@ -253,14 +193,44 @@ export default defineConfig([
},
},

// js parserOptions override to suppress project service warnings for loose JS files
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
languageOptions: {
parserOptions: {
allowDefaultProject: true,
noWarnOnMultipleProjects: true, // suppress informational warning
},
},
},
// tests: relax package import restriction
{
files: ['**/__test__/**', '**/__tests__/**', '**/*.test.ts', '**/*.test.js'],
rules: {
'import-x/no-relative-packages': 0,
'security/detect-non-literal-fs-filename': 0
},
},

// CLI tools
{
files: ['**/cli/**'],
rules: {
'no-console': 0,
'security/detect-non-literal-fs-filename': 0
},
},

// misc rule overrides
{
rules: {
'no-restricted-syntax': 0,
'no-underscore-dangle': 0,
'no-await-in-loop': 0,
'no-plusplus': [2, { allowForLoopAfterthoughts: true }],
'unicorn/prefer-top-level-await': 0, // top level await is not available in commonjs
'unicorn/prefer-top-level-await': 0,
'import-x/no-relative-packages': 1,
'no-relative-import-paths/no-relative-import-paths': 1
},
},
]);
1 change: 1 addition & 0 deletions internal/events/.spectral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: ["spectral:oas", "spectral:asyncapi", "spectral:arazzo"]
10 changes: 10 additions & 0 deletions internal/events/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
testPathIgnorePatterns: ["<rootDir>/dist/"],
moduleFileExtensions: ["ts", "js", "json", "node"],
transform: {
"^.+\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.jest.json" }],
},
};
Loading
Loading