Skip to content

Commit

Permalink
fix(eslint-plugin): [prefer-readonly] TypeError when having comp… (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
eranshabi authored and bradzacher committed Jul 25, 2019
1 parent 2b942ba commit 211b1b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/prefer-readonly.ts
Expand Up @@ -179,7 +179,7 @@ export default util.createRule<Options, MessageIds>({
const tsNode = parserServices.esTreeNodeToTSNodeMap.get<
ts.PropertyAccessExpression
>(node);
if (classScopeStack.length !== 0) {
if (classScopeStack.length !== 0 && !node.computed) {
handlePropertyAccessExpression(
tsNode,
tsNode.parent,
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint-plugin/tests/rules/prefer-readonly.test.ts
Expand Up @@ -215,6 +215,11 @@ ruleTester.run('prefer-readonly', rule, {
},
],
},
`class TestComputedParameter {
public mutate() {
this['computed'] = 1;
}
}`,
],
invalid: [
{
Expand Down

0 comments on commit 211b1b5

Please sign in to comment.