Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/drizzle-utils/tests/connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function buildDbOptions(overrides: Partial<commonDbFullV1Type> = {}): commonDbFu
schema: 'public',
ssl: { enabled: false },
...overrides,
} as commonDbFullV1Type;
};
}

describe('#createConnectionOptions', function () {
Expand Down
32 changes: 17 additions & 15 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
},
"repository": "github:MapColonies/infra-packages",
"peerDependencies": {
"eslint": "^9.19.0",
"eslint-plugin-jest": "^28.11.0 || ^29.0.0",
"@vitest/eslint-plugin": "^1.6.7",
"eslint": "^10.0.0",
"eslint-plugin-jest": "^29.13.0",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.1.0 || ^7.0.0",
"@vitest/eslint-plugin": "^1.6.7",
"globals": "^15.14.0 || ^17.0.0"
},
"peerDependenciesMeta": {
Expand All @@ -70,25 +70,27 @@
}
},
"dependencies": {
"@eslint/js": "^9.19.0",
"eslint-import-resolver-typescript": "^4.0.0",
"@eslint/compat": "^2.1.0",
"@eslint/js": "^10.0.1",
"@map-colonies/eslint-plugin": "workspace:^",
"@typescript-eslint/parser": "^8.60.1",
"eslint-config-prettier": "^10.0.1",
"eslint-import-resolver-typescript": "^4.0.0",
"eslint-plugin-import-x": "^4.16.1",
"@typescript-eslint/parser": "^8.23.0",
"typescript-eslint": "^8.23.0",
"eslint-plugin-unicorn": "^63.0.0"
"eslint-plugin-import-x": "^4.16.2",
"eslint-plugin-unicorn": "^63.0.0",
"typescript-eslint": "^8.60.1"
},
"devDependencies": {
"@map-colonies/tsconfig": "workspace:^",
"@types/node": "catalog:",
"@vitest/eslint-plugin": "1.6.19",
"eslint": "catalog:",
"typescript": "catalog:",
"eslint-plugin-react-hooks": "7.0.1",
"eslint-plugin-jest": "29.12.1",
"eslint-import-resolver-typescript": "^4.0.0",
"eslint-plugin-jest": "29.15.2",
"eslint-plugin-react": "7.37.5",
"@vitest/eslint-plugin": "1.6.7",
"vitest-config": "workspace:^",
"vitest": "catalog:"
"eslint-plugin-react-hooks": "7.1.1",
"typescript": "catalog:",
"vitest": "catalog:",
"vitest-config": "workspace:^"
}
}
26 changes: 14 additions & 12 deletions packages/eslint-config/src/configs/jest.mts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import type jestPluginType from 'eslint-plugin-jest';
import { config } from '../helpers.mjs';
import { defineConfig } from 'eslint/config';
import { importOrThrow } from '../internal/helpers.js';

const jestPlugin = await importOrThrow<typeof jestPluginType>('eslint-plugin-jest');

const jestConfig = config({
name: 'map-colonies/jest/rules',
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'],
plugins: { jest: jestPlugin },
languageOptions: {
globals: jestPlugin.environments.globals.globals,
const jestConfig = defineConfig([
{
name: 'map-colonies/jest/rules',
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx'],
plugins: { jest: jestPlugin },
languageOptions: {
globals: jestPlugin.environments.globals.globals,
},
rules: {
...jestPlugin.configs.recommended.rules,
...jestPlugin.configs.style.rules,
},
},
rules: {
...jestPlugin.configs.recommended.rules,
...jestPlugin.configs.style.rules,
},
});
]);

/**
* The default export for the Jest configuration.
Expand Down
56 changes: 33 additions & 23 deletions packages/eslint-config/src/configs/react.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type reactPluginType from 'eslint-plugin-react';
import type { plugin } from 'typescript-eslint';
import type tseslint from 'typescript-eslint';
import { config } from '../helpers.mjs';
import { fixupPluginRules } from '@eslint/compat';
import { defineConfig } from 'eslint/config';
import { importOrThrow } from '../internal/helpers.js';

type PluginReactHooks = typeof plugin & { configs: { recommended: { rules: tseslint.ConfigWithExtends['rules'] } } };
Expand All @@ -10,30 +11,39 @@ const reactPlugin = await importOrThrow<typeof reactPluginType>('eslint-plugin-r
const pluginReactHooks = await importOrThrow<PluginReactHooks>('eslint-plugin-react-hooks');
const importedGlobals = await importOrThrow<{ browser: Exclude<tseslint.ConfigArray[0]['languageOptions'], undefined>['globals'] }>('globals');

const reactRules = config(reactPlugin.configs.flat.recommended ?? {}, reactPlugin.configs.flat['jsx-runtime'] ?? {}, {
name: 'map-colonies/react/rules',
files: ['**/*.tsx'],
languageOptions: {
globals: importedGlobals.browser,
},
settings: {
react: {
version: 'detect',
const fixedReactPlugin = fixupPluginRules(reactPlugin);
const fixedPlugins = { react: fixedReactPlugin };

const reactRules = defineConfig([
{ ...reactPlugin.configs.flat.recommended, plugins: fixedPlugins },
{ ...reactPlugin.configs.flat['jsx-runtime'], plugins: fixedPlugins },
{
name: 'map-colonies/react/rules',
files: ['**/*.tsx'],
languageOptions: {
globals: importedGlobals.browser,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'react/boolean-prop-naming': 'error',
'react/hook-use-state': 'error',
'react/prop-types': 'off',
},
},
rules: {
'react/boolean-prop-naming': 'error',
'react/hook-use-state': 'error',
'react/prop-types': 'off',
},
});
]);

const reactHooksRules = config({
name: 'map-colonies/react-hooks/rules',
files: ['**/*.tsx'],
plugins: { 'react-hooks': pluginReactHooks },
rules: pluginReactHooks.configs.recommended.rules,
});
const reactHooksRules = defineConfig([
{
name: 'map-colonies/react-hooks/rules',
files: ['**/*.tsx'],
plugins: { 'react-hooks': pluginReactHooks },
rules: pluginReactHooks.configs.recommended.rules,
},
]);

/**
* Combined React and React Hooks ESLint configuration
Expand All @@ -53,4 +63,4 @@ const reactHooksRules = config({
*
* export default config(reactConfig);
*/
export default config(reactRules, reactHooksRules);
export default defineConfig([reactRules, reactHooksRules]);
1 change: 0 additions & 1 deletion packages/eslint-config/src/configs/ts-base.mts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ const combinedConfig = defineConfig(
jestTurnedOffRules,
reactNamingConventions,
unicornRules,
//@ts-expect-error it works and a known issue https://github.com/un-ts/eslint-plugin-import-x/issues/421
importFlatConfigs.recommended,
{ name: 'import-x/typescript', ...importFlatConfigs.typescript },
importRulesAndConfig,
Expand Down
21 changes: 7 additions & 14 deletions packages/eslint-config/src/helpers.mts
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { config as importedConfig } from 'typescript-eslint';
import { defineConfig } from 'eslint/config';

/**
* Utility function to make it easy to strictly type your "Flat" config file
* @example
* ```js
* // @ts-check
*
* import eslint from '@eslint/js';
* import tseslint from 'typescript-eslint';
* import { defineConfig } from '@map-colonies/eslint-config/helpers';
* import tsBaseConfig from '@map-colonies/eslint-config/ts-base';
*
* export default tseslint.config(
* eslint.configs.recommended,
* tseslint.configs.recommended,
* {
* rules: {
* '@typescript-eslint/array-type': 'error',
* },
* },
* );
* export default defineConfig([tsBaseConfig]);
* ```
*/
const config = importedConfig;
export { defineConfig };

export { config };
/** @deprecated Use `defineConfig` from 'eslint/config' instead */
export { defineConfig as config };
2 changes: 1 addition & 1 deletion packages/eslint-config/tests/configs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const configs = [

describe('configs', function () {
it.each(configs)('$name should be a valid eslint config', function (testObject) {
const linter = new Linter({ configType: 'flat' });
const linter = new Linter();
const action = () => linter.verify('const a = 1', testObject.config as object, { filename: testObject.filename });

expect(action).not.toThrow();
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
},
"repository": "github:MapColonies/infra-packages",
"peerDependencies": {
"eslint": "^9.39.0"
"eslint": "^10.0.0"
},
"dependencies": {
"@typescript-eslint/utils": "^8.53.0"
"@typescript-eslint/utils": "^8.60.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "catalog:",
"@map-colonies/tsconfig": "workspace:^",
"@types/node": "catalog:",
"@typescript-eslint/rule-tester": "8.53.0",
"@typescript-eslint/rule-tester": "8.60.1",
"eslint": "catalog:",
"publint": "catalog:",
"rimraf": "catalog:",
"typescript": "catalog:",
"typescript-eslint": "8.49.0",
"typescript-eslint": "8.60.1",
"vitest": "catalog:",
"vitest-config": "workspace:^"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const plugin = {
'pino-safety-no-swallowed-args': noSwallowedArgs,
'pino-safety-prefer-standard-error-key': preferStandardErrorKey,
},
configs: {} as Record<string, Linter.Config>,
configs: {} as Record<'pino-safety' | 'recommended', Linter.Config>,
};

// Assign configs after plugin definition so we can reference it
Expand Down
2 changes: 1 addition & 1 deletion packages/js-logger/scripts/generateVersionFile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const packageJson = readPackageJsonSync();
const version = packageJson.version;
const versionFile = 'src/version.ts';

const content = `/* prettier-ignore */\n/* eslint-disable*/\nexport const PACKAGE_VERSION = '${version}';\n`;
const content = `export const PACKAGE_VERSION = '${version}';\n`;

writeFileSync(versionFile, content);
5 changes: 2 additions & 3 deletions packages/vitest-utils/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('getPathAlias', function () {

describe('reporters', function () {
it('should include "default" and "html" reporters outside CI', async function () {
vi.stubEnv('GITHUB_ACTIONS', undefined as unknown as string);
vi.stubEnv('GITHUB_ACTIONS', undefined);
vi.resetModules();
const { reporters } = await import('../src/reporters.js');

Expand Down Expand Up @@ -131,8 +131,7 @@ describe('setupOpenapi', function () {

afterEach(function () {
vi.restoreAllMocks();
// @ts-expect-error - reset global expect to avoid conflicts with other test frameworks
globalThis.expect = undefined as unknown as typeof expect;
globalThis.expect = undefined;
});

it('should call jestOpenApi with the provided path', async function () {
Expand Down
Loading
Loading