diff --git a/rules/no-unused-properties.js b/rules/no-unused-properties.js index 8997e3ada0..50cbe643bf 100644 --- a/rules/no-unused-properties.js +++ b/rules/no-unused-properties.js @@ -123,12 +123,20 @@ const create = context => { const nextReferences = references .map(reference => { + const {parent} = reference.identifier; + if (reference.init) { + if ( + parent.type === 'VariableDeclarator' && + parent.parent.type === 'VariableDeclaration' && + parent.parent.parent.type === 'ExportNamedDeclaration' + ) { + return {identifier: parent}; + } + return null; } - const {parent} = reference.identifier; - if (parent.type === 'MemberExpression') { if ( isMemberExpressionAssignment(parent) || diff --git a/test/no-unused-properties.js b/test/no-unused-properties.js index 127b525cf4..a0b5f157b0 100644 --- a/test/no-unused-properties.js +++ b/test/no-unused-properties.js @@ -280,6 +280,15 @@ var foo = { }; export {foo}; `, + + ` +export const foo = { + a: 1, + b: 2 +}; +console.log(foo.a); +`, + ` var foo = { a: 1