no const assignment

pull/9723/head
Simon Holthausen 3 years ago
parent a763756a58
commit 7323d7447c

@ -649,7 +649,19 @@ export const validation_runes_js = {
* @param {boolean} is_binding * @param {boolean} is_binding
*/ */
function validate_no_const_assignment(node, argument, scope, is_binding) { function validate_no_const_assignment(node, argument, scope, is_binding) {
if (argument.type === 'Identifier') { if (argument.type === 'ArrayPattern') {
for (const element of argument.elements) {
if (element) {
validate_no_const_assignment(node, element, scope, is_binding);
}
}
} else if (argument.type === 'ObjectPattern') {
for (const element of argument.properties) {
if (element.type === 'Property') {
validate_no_const_assignment(node, element.value, scope, is_binding);
}
}
} else if (argument.type === 'Identifier') {
const binding = scope.get(argument.name); const binding = scope.get(argument.name);
if (binding?.declaration_kind === 'const' && binding.kind !== 'each') { if (binding?.declaration_kind === 'const' && binding.kind !== 'each') {
error( error(

@ -1,3 +0,0 @@
import { test } from '../../test';
export default test({ skip: true });

@ -1,7 +1,7 @@
[ [
{ {
"code": "assignment-to-const", "code": "invalid-const-assignment",
"message": "You are assigning to a const", "message": "Invalid assignment to const variable",
"start": { "start": {
"line": 13, "line": 13,
"column": 24 "column": 24

@ -1,3 +0,0 @@
import { test } from '../../test';
export default test({ skip: true });

@ -1,7 +1,7 @@
[ [
{ {
"code": "assignment-to-const", "code": "invalid-const-assignment",
"message": "You are assigning to a const", "message": "Invalid assignment to const variable",
"start": { "start": {
"line": 14, "line": 14,
"column": 3 "column": 3

@ -1,3 +0,0 @@
import { test } from '../../test';
export default test({ skip: true });

@ -1,7 +1,7 @@
[ [
{ {
"code": "assignment-to-const", "code": "invalid-const-assignment",
"message": "You are assigning to a const", "message": "Invalid assignment to const variable",
"start": { "start": {
"line": 17, "line": 17,
"column": 2 "column": 2

@ -1,3 +0,0 @@
import { test } from '../../test';
export default test({ skip: true });

@ -1,7 +1,7 @@
[ [
{ {
"code": "assignment-to-const", "code": "invalid-const-assignment",
"message": "You are assigning to a const", "message": "Invalid assignment to const variable",
"start": { "start": {
"line": 3, "line": 3,
"column": 1 "column": 1

@ -1,3 +0,0 @@
import { test } from '../../test';
export default test({ skip: true });

@ -1,7 +1,7 @@
[ [
{ {
"code": "assignment-to-const", "code": "invalid-const-assignment",
"message": "You are assigning to a const", "message": "Invalid assignment to const variable",
"start": { "start": {
"line": 3, "line": 3,
"column": 1 "column": 1

@ -1,3 +0,0 @@
import { test } from '../../test';
export default test({ skip: true });

@ -1,7 +1,7 @@
[ [
{ {
"code": "assignment-to-const", "code": "invalid-const-assignment",
"message": "You are assigning to a const", "message": "Invalid assignment to const variable",
"start": { "start": {
"line": 16, "line": 16,
"column": 2 "column": 2

Loading…
Cancel
Save