Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Update .eslintrc for Stimulus to Support "static" Syntax #441

Closed
htoo-eain-lwin opened this issue Jul 11, 2023 · 1 comment · Fixed by #442
Closed

Fix: Update .eslintrc for Stimulus to Support "static" Syntax #441

htoo-eain-lwin opened this issue Jul 11, 2023 · 1 comment · Fixed by #442
Assignees

Comments

@htoo-eain-lwin
Copy link
Contributor

htoo-eain-lwin commented Jul 11, 2023

Issue

The current ESLint configuration does not support the "static" syntax used in the codebase.
This leads to parsing errors and unexpected token issues when running yarn eslint, specifically with statements like static targets = ['foo', 'bar'];.

We use static in our stimulus controllers.
eg.

// hello_controller.js
import { Controller } from "stimulus"

export default class extends Controller {
  static targets = [ "name", "output" ]

  greet() {
    this.outputTarget.textContent =
      `Hello, ${this.nameTarget.value}!`
  }
}

Expected

  • yarn eslint should not throw error for valid JS
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
    static targets = [ "foo" ]
}

Describe what should be the correct behaviour.

  • To resolve this, we need to update the .eslintrc file with the appropriate "parserOptions" configuration.

Steps to reproduce

  1. run yarn eslint on any file which use static keyword which used to define static methods
@andyduong1920
Copy link
Member

@htoo-eain-lwin I think it would be nice if you mention we used the static for Stimulus controllers ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants