Skip to content

Commit

Permalink
chore(eslint-plugin): remove unused no-qualified-construct rule (#28779)
Browse files Browse the repository at this point in the history
The `no-qualified-construct` rule is meant to make sure there are no collisions with `constructs.Construct` and `core.Construct`. This was helpful when reducing merge conflicts between v1 and v2 branches. 

We no longer have this issue, and CDK v2 does not include `core.Constructs`; we use `constructs.Construct` everywhere.

Also I documented our other eslint-plugin rules that seem to still make sense in the README.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc authored Jan 19, 2024
1 parent 2511956 commit 0cab968
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 180 deletions.
1 change: 0 additions & 1 deletion packages/awslint/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = {
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
rules: {
'@aws-cdk/no-core-construct': ['error'],
'@aws-cdk/no-qualified-construct': ['error'],
'@aws-cdk/invalid-cfn-imports': ['error'],
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
'@typescript-eslint/no-require-imports': ['error'],
Expand Down
1 change: 0 additions & 1 deletion tools/@aws-cdk/cdk-build-tools/config/eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module.exports = {
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
rules: {
'@aws-cdk/no-core-construct': ['error'],
'@aws-cdk/no-qualified-construct': ['error'],
'@aws-cdk/invalid-cfn-imports': ['error'],
'@aws-cdk/no-literal-partition': ['error'],
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
Expand Down
6 changes: 6 additions & 0 deletions tools/@aws-cdk/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ Eslint plugin for the CDK repository. Contains rules that need to be applied spe

## Rules

* `invalid-cfn-imports`: Ensures that imports of `Cfn<Resource>` L1 resources come from the stable
`aws-cdk-lib` package and not the alpha packages. Rule only applies to alpha modules.

* `no-core-construct`: Forbid the use of `Construct` and `IConstruct` from the "@aws-cdk/core" module.
Instead use `Construct` and `IConstruct` from the "constructs" module.
Rule only applies to typescript files under the `test/` folder.

* `no-literal-partition`: Forbids the use of literal partitions (usually `aws`). Instead, use
`Aws.PARTITION` to ensure that the code works for other partitions too.

## How to add new rules

* Make a new file in `lib/rules`. It should export one function called `create`. The
Expand Down
1 change: 0 additions & 1 deletion tools/@aws-cdk/eslint-plugin/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const rules = {
'no-core-construct': require('./rules/no-core-construct'),
'no-qualified-construct': require('./rules/no-qualified-construct'),
'invalid-cfn-imports': require('./rules/invalid-cfn-imports'),
'no-literal-partition': require('./rules/no-literal-partition'),
};
134 changes: 0 additions & 134 deletions tools/@aws-cdk/eslint-plugin/lib/rules/no-qualified-construct.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion tools/@aws-cdk/pkglint/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = {
ignorePatterns: ['*.js', '*.d.ts', 'node_modules/', '*.generated.ts'],
rules: {
'@aws-cdk/no-core-construct': ['error'],
'@aws-cdk/no-qualified-construct': ['error'],
'@aws-cdk/invalid-cfn-imports': ['error'],
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
'@typescript-eslint/no-require-imports': ['error'],
Expand Down

0 comments on commit 0cab968

Please sign in to comment.