Skip to content

Commit

Permalink
migrate formatting to eslint v9
Browse files Browse the repository at this point in the history
Signed-off-by: Kangrui Johann Ye <kangrui.ye@cloudflight.io>
  • Loading branch information
strawberry-choco committed Oct 16, 2024
1 parent 0a3f8ea commit a3241a8
Show file tree
Hide file tree
Showing 23 changed files with 258 additions and 150 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.format.js

This file was deleted.

7 changes: 3 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import tseslint from 'typescript-eslint';
import {includeIgnoreFile} from '@eslint/compat';
import {dirname, resolve} from 'node:path';
import {fileURLToPath} from 'node:url';
import { cloudflightTypescriptConfig } from '@cloudflight/eslint-plugin-typescript';
import {cloudflightTypescriptConfig} from '@cloudflight/eslint-plugin-typescript';

const filename = fileURLToPath(import.meta.url);
const directory = dirname(filename);
Expand All @@ -18,16 +18,15 @@ export default tseslint.config(
'packages/eslint-plugin-typescript/src/configs/index.ts',
'packages/eslint-plugin-typescript/src/configs/json.ts',
'packages/eslint-plugin-typescript/src/configs/package.ts',
'packages/eslint-plugin-typescript/src/configs/format.ts',
'packages/eslint-plugin-typescript/src/configs/rxjs.ts',
'packages/eslint-plugin-typescript/src/rules/package/*',
'packages/eslint-plugin-typescript/src/rules/ts-config/*',
'packages/eslint-plugin-typescript/src/rules/typescript/*.spec.ts',
'scripts/*',
'.eslintrc.format.js',
'eslint.config.mjs',
'eslint.format.mjs',
'jest.config*.ts',
]
],
},
...cloudflightTypescriptConfig,
{
Expand Down
22 changes: 22 additions & 0 deletions eslint.format.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import tseslint from 'typescript-eslint';
import {includeIgnoreFile} from '@eslint/compat';
import {dirname, resolve} from 'node:path';
import {fileURLToPath} from 'node:url';
import {cloudflightTypescriptFormatConfig} from '@cloudflight/eslint-plugin-typescript';

const filename = fileURLToPath(import.meta.url);
const directory = dirname(filename);
const gitignorePath = resolve(directory, '.gitignore');

export default tseslint.config(
includeIgnoreFile(gitignorePath),
...cloudflightTypescriptFormatConfig,
// {
// languageOptions: {
// parserOptions: {
// project: ['./packages/*/tsconfig.json', './packages/*/tsconfig.spec.json'],
// tsconfigRootDir: import.meta.dirname,
// },
// },
// },
);
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"description": "",
"scripts": {
"build": "yarn workspaces foreach -pA --topological-dev run build-package",
"lint": "eslint .",
"lint": "eslint . && eslint -c eslint.format.mjs .",
"lint:format": "eslint -c eslint.format.mjs .",
"test": "yarn workspaces foreach -pA run test-package",
"postinstall": "husky",
"publish-workspaces": "node ./scripts/prepare.js && yarn workspaces foreach -A --no-private npm publish"
Expand All @@ -30,6 +31,7 @@
"devDependencies": {
"@eslint/compat": "1.2.0",
"@eslint/js": "9.11.1",
"@stylistic/eslint-plugin": "2.9.0",
"@types/eslint": "9.6.1",
"@types/eslint__js": "8.42.3",
"@types/estree": "1.0.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const cloudflightAngularTypescriptConfig = tseslint.config(
...eslintRules,
...typescriptEslintRules,
...angularEslintRules,
}
},
},
);

Expand All @@ -35,8 +35,8 @@ export const cloudflightAngularTemplateConfig = tseslint.config(
...angularTemplateEslintRules,
// todo: this should be its own config
// ...formatAngularTemplateEslintRules,
}
}
},
},
);

export const cloudflightAngularConfig = tseslint.config(
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-node/src/configs/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function warningEntryToError(value: TSESLint.Linter.RuleEntry): TSESLint.Linter.
function warningLevelToError(level: TSESLint.Linter.RuleLevel): TSESLint.Linter.RuleLevel {
if (level === 'warn') {
return 'error';
} else if (level === 1) {
}
else if (level === 1) {
return 'error';
}

Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin-node/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import tseslint from 'typescript-eslint';
import { cloudflightTypescriptConfig } from '@cloudflight/eslint-plugin-typescript';
import {cloudflightTypescriptConfig} from '@cloudflight/eslint-plugin-typescript';
import nounsanitized from 'eslint-plugin-no-unsanitized';
import pluginSecurity from 'eslint-plugin-security';
import pluginNode from 'eslint-plugin-n';
Expand All @@ -21,6 +21,6 @@ export const cloudflightNodeConfig = tseslint.config(
...nodeRules,
...securityRules,
...importEslintRules,
}
},
},
);
4 changes: 2 additions & 2 deletions packages/eslint-plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import tseslint from 'typescript-eslint';
import {
cloudflightTypescriptBaseConfig,
cloudflightTypescriptConfig, cloudflightTypescriptDisableTypeCheckedConfig,
cloudflightTypescriptImportConfig
cloudflightTypescriptImportConfig,
} from '@cloudflight/eslint-plugin-typescript';
import type {TSESLint} from '@typescript-eslint/utils';
import * as tsParser from '@typescript-eslint/parser';
Expand Down Expand Up @@ -51,7 +51,7 @@ export const cloudflightReactConfig = tseslint.config(
rules: {
...pluginReactHooks.configs.recommended.rules,
...reactRules,
}
},
},
{
files: ['**/*.{js,jsx,mjs,cjs}'],
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-typescript/src/configs/custom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TSESLint} from '@typescript-eslint/utils';
import type {TSESLint} from '@typescript-eslint/utils';

import {NoMomentJsRuleName} from '../rules/typescript/no-moment-js';
import {NoOnEventAssignName} from '../rules/typescript/no-on-event-assign';
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-typescript/src/configs/eslint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TSESLint} from '@typescript-eslint/utils';
import type {TSESLint} from '@typescript-eslint/utils';

export const eslintRules: TSESLint.Linter.RulesRecord = {
complexity: ['error', {max: 20}],
Expand Down
Loading

0 comments on commit a3241a8

Please sign in to comment.