Skip to content
Permalink
Browse files

fix(eslint-plugin): [naming-convention] ignore properties inside obje…

…ct patterns (#2566)
  • Loading branch information
JoshuaKGoldberg committed Sep 21, 2020
1 parent 1329294 commit 53a3cbc6f002e55135efbdf4982a3ad308ac708b
@@ -579,7 +579,7 @@ export default util.createRule<Options, MessageIds>({

// #region property

'Property[computed = false][kind = "init"][value.type != "ArrowFunctionExpression"][value.type != "FunctionExpression"][value.type != "TSEmptyBodyFunctionExpression"]'(
':not(ObjectPattern) > Property[computed = false][kind = "init"][value.type != "ArrowFunctionExpression"][value.type != "FunctionExpression"][value.type != "TSEmptyBodyFunctionExpression"]'(
node: TSESTree.PropertyNonComputedName,
): void {
const modifiers = new Set<Modifiers>([Modifiers.public]);
@@ -906,6 +906,20 @@ ruleTester.run('naming-convention', rule, {
},
],
},
{
code: `
class SomeClass {
static OtherConstant = 'hello';
}
export const { OtherConstant: otherConstant } = SomeClass;
`,
parserOptions,
options: [
{ selector: 'property', format: ['PascalCase'] },
{ selector: 'variable', format: ['camelCase'] },
],
},
],
invalid: [
{
@@ -1282,5 +1296,25 @@ ruleTester.run('naming-convention', rule, {
],
errors: [{ messageId: 'doesNotMatchFormatTrimmed' }],
},
{
code: `
class SomeClass {
static otherConstant = 'hello';
}
export const { otherConstant } = SomeClass;
`,
parserOptions,
options: [
{ selector: 'property', format: ['PascalCase'] },
{ selector: 'variable', format: ['camelCase'] },
],
errors: [
{
line: 3,
messageId: 'doesNotMatchFormat',
},
],
},
],
});

0 comments on commit 53a3cbc

Please sign in to comment.