Skip to content

Commit

Permalink
migrate angular config (#238)
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 authored Oct 7, 2024
1 parent c1d9561 commit da2c071
Show file tree
Hide file tree
Showing 21 changed files with 184 additions and 270 deletions.
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default tseslint.config(
// these files are temporarily disabled for linting
// until we are done with migrating everything to v9
ignores: [
'packages/eslint-plugin-angular/*',
'packages/eslint-plugin-angular/src/configs/format-template.ts',
'packages/eslint-plugin-node/*',
'packages/eslint-plugin-react/*',
'packages/eslint-plugin-typescript/src/configs/index.ts',
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"private": true,
"volta": {
"node": "20.12.2",
Expand Down Expand Up @@ -28,9 +28,6 @@
"author": "Cloudflight GmbH",
"license": "Apache-2.0",
"devDependencies": {
"@angular-eslint/eslint-plugin": "17.3.0",
"@angular-eslint/eslint-plugin-template": "17.3.0",
"@angular-eslint/template-parser": "17.3.0",
"@eslint/compat": "1.1.1",
"@eslint/js": "9.11.1",
"@types/eslint": "9.6.1",
Expand All @@ -42,6 +39,7 @@
"@typescript-eslint/parser": "8.8.0",
"@typescript-eslint/utils": "8.8.0",
"@vue/eslint-config-typescript": "14.0.0",
"angular-eslint": "18.3.1",
"eslint": "9.11.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-json-es": "1.6.0",
Expand Down
41 changes: 27 additions & 14 deletions packages/eslint-plugin-angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ You can find the directory of all rules including their reasoning [here](src/con
The following dependencies are required:

```
"@cloudflight/eslint-plugin-typescript": ">=0.26.0",
"eslint": ">=9.0.0 < 10.0.0"
```

Expand All @@ -27,23 +26,37 @@ In your `package.json` add the following:

The plugin provides 3 different configurations:

- @cloudflight/angular/recommended
- cloudflightAngularConfig
- Both of the below 2 configurations
- @cloudflight/angular/recommended-html
- cloudflightAngularTemplateConfig
- Only contains rules for HTML files
- @cloudflight/angular/recommended-typescript
- cloudflightAngularTypescriptConfig
- Only contains rules for TS files

Now open your `.eslintrc.js` and add one of the configurations:

```
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
...
extends: ['plugin:@cloudflight/angular/recommended'],
...
};
Now open your `eslint.config.mts` and add one of the configurations:

```ts
import { cloudflightAngularConfig } from '@cloudflight/eslint-plugin-angular';
import { includeIgnoreFile } from '@eslint/compat';
import { dirname, normalize, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const gitignorePath = normalize(resolve(__dirname, '.gitignore'));

export default [
includeIgnoreFile(gitignorePath),
...cloudflightAngularConfig,
{
languageOptions: {
parserOptions: {
project: ['tsconfig.*?.json'],
tsconfigRootDir: import.meta.dirname,
},
},
},
];
```

## Formatting
Expand Down
11 changes: 4 additions & 7 deletions packages/eslint-plugin-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-angular",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "Cloudflight eslint-plugin & eslint-config for angular",
"volta": {
"extends": "../../package.json"
Expand All @@ -22,17 +22,14 @@
"publishConfig": {
"access": "public"
},
"private": true,
"scripts": {
"build-packagex": "tsc"
"build-package": "tsc"
},
"dependencies": {
"@angular-eslint/eslint-plugin": "^17.3.0",
"@angular-eslint/eslint-plugin-template": "^17.3.0",
"@angular-eslint/template-parser": "^17.3.0"
"@cloudflight/eslint-plugin-typescript": "workspace:*",
"angular-eslint": "18.3.1"
},
"peerDependencies": {
"@cloudflight/eslint-plugin-typescript": "workspace:*",
"eslint": ">=9.0.0 < 10.0.0"
},
"devDependencies": {
Expand Down
13 changes: 0 additions & 13 deletions packages/eslint-plugin-angular/src/configs/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

45 changes: 43 additions & 2 deletions packages/eslint-plugin-angular/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
export {configs} from './configs';
export {rules} from './rules';
import tseslint from 'typescript-eslint';
import angular from 'angular-eslint';
import {cloudflightTypescriptConfig} from '@cloudflight/eslint-plugin-typescript';
import {eslintRules} from './configs/eslint';
import {typescriptEslintRules} from './configs/typescript-eslint';
import {angularEslintRules} from './configs/angular-eslint';
import {angularTemplateEslintRules} from './configs/angular-eslint-template';

export const cloudflightAngularTypescriptConfig = tseslint.config(
{
files: ['**/*.{ts,mts,cts}'],
extends: [
...cloudflightTypescriptConfig,
...angular.configs.tsRecommended,
],
processor: angular.processInlineTemplates,
rules: {
...eslintRules,
...typescriptEslintRules,
...angularEslintRules,
}
},
);

export const cloudflightAngularTemplateConfig = tseslint.config(
{
files: ['**/*.html'],
extends: [
...angular.configs.templateRecommended,
...angular.configs.templateAccessibility,
],
rules: {
...angularTemplateEslintRules,
// todo: this should be its own config
// ...formatAngularTemplateEslintRules,
}
}
);

export const cloudflightAngularConfig = tseslint.config(
...cloudflightAngularTypescriptConfig,
...cloudflightAngularTemplateConfig,
);
3 changes: 0 additions & 3 deletions packages/eslint-plugin-angular/src/rules/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/eslint-plugin-angular/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"forceConsistentCasingInFileNames": true,

"strict": true,
"exactOptionalPropertyTypes": true,
"exactOptionalPropertyTypes": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-node",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "Cloudflight eslint-plugin & eslint-config for node",
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-react",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "Cloudflight eslint-plugin & eslint-config for React",
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-typescript",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "Cloudflight eslint-plugin & eslint-config for typescript",
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-vue",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "Cloudflight eslint-plugin & eslint-config for vue",
"volta": {
"extends": "../../package.json"
Expand Down
Loading

0 comments on commit da2c071

Please sign in to comment.