Skip to content

Commit 67ef64d

Browse files
JS-823 Improve S2068: Add support for TS PropertyDefinition (#5917)
1 parent 0857b0b commit 67ef64d

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/jsts/src/rules/S2068/rule.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import type { Rule } from 'eslint';
2020
import type estree from 'estree';
21+
import type { TSESTree } from '@typescript-eslint/utils';
2122
import { generateMeta, isStringLiteral } from '../helpers/index.js';
2223
import path from 'node:path';
2324
import { FromSchema } from 'json-schema-to-ts';
@@ -59,6 +60,10 @@ export const rule: Rule.RuleModule = {
5960
const literal = node as estree.Literal;
6061
checkLiteral(context, literalRegExp, literal);
6162
},
63+
PropertyDefinition: (node: estree.Node) => {
64+
const property = node as TSESTree.PropertyDefinition;
65+
checkAssignment(context, lowerCaseVariableNames, property.key as estree.Node, property.value as estree.Node);
66+
},
6267
};
6368
},
6469
};

packages/jsts/src/rules/S2068/unit.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ describe('S2068', () => {
7575
code: `
7676
let my_pwd;
7777
my_pwd = "foo";
78+
`,
79+
options,
80+
errors: 1,
81+
},
82+
{
83+
code: `
84+
export class Example {
85+
public testingPassword = 'foo';
86+
}
7887
`,
7988
options,
8089
errors: 1,

0 commit comments

Comments
 (0)