Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FP S1848 (constructor-for-side-effects): Make exception for AWS CDK resources #4554

Merged
merged 1 commit into from
Feb 5, 2024
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
Original file line number Diff line number Diff line change
@@ -1,75 +1,5 @@
{
"file-for-rules:S4423.js": [
3
],
"file-for-rules:S5332.js": [
6,
11,
15,
41,
60,
76,
81
],
"file-for-rules:S6245.js": [
3,
9,
14
],
"file-for-rules:S6252.js": [
4,
9
],
"file-for-rules:S6265.js": [
8,
14,
24
],
"file-for-rules:S6270.js": [
104
],
"file-for-rules:S6281.js": [
3,
8
],
"file-for-rules:S6302.js": [
47,
82
],
"file-for-rules:S6303.js": [
3,
4
],
"file-for-rules:S6304.js": [
49,
78,
105
],
"file-for-rules:S6319.js": [
2
],
"file-for-rules:S6321.js": [
69,
108,
118,
126
],
"file-for-rules:S6327.js": [
3,
4
],
"file-for-rules:S6329.js": [
86,
123,
130,
138
],
"file-for-rules:S6332.js": [
3,
4
],
"file-for-rules:S6333.js": [
28,
48
]
}
2 changes: 1 addition & 1 deletion packages/jsts/src/rules/S1848/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ function isException(
}

const fqn = getFullyQualifiedName(context, node);
return fqn === 'vue' || fqn === '@ag-grid-community.core.Grid';
return fqn === 'vue' || fqn === '@ag-grid-community.core.Grid' || fqn?.startsWith('aws-cdk-lib');
}
15 changes: 13 additions & 2 deletions packages/jsts/src/rules/S1848/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { RuleTester } from 'eslint';
import { TypeScriptRuleTester } from '../tools';
import { rule } from './';

const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2018, sourceType: 'module' } });
const ruleTester = new TypeScriptRuleTester();

ruleTester.run(`Objects should not be created to be dropped immediately without being used`, rule, {
valid: [
Expand Down Expand Up @@ -72,6 +72,17 @@ ruleTester.run(`Objects should not be created to be dropped immediately without
new Grid();
`,
},
{
code: `
import * as s3 from 'aws-cdk-lib/aws-s3';
export class Stack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

new s3.Bucket(this, 'TempBucket', {});
}
}`,
},
],
invalid: [
{
Expand Down
Loading