Reputation: 1474
I am building a in-browser IDE and am looking for a way to run ESlint on the JS code my users are writing. I am using react and the code that was written is stored in the state as a string. Is there any tool to just take that string and execute ESlint on it? I did not find anything.
If this is not available: Any ideas how to do what i want to do in the browser on the client?
Upvotes: 4
Views: 1474
Reputation: 4542
Officially, ESLint doesn't support running in the browser, but it is possible. When run on Node.js, ESLint reads built-in rules, plugins, and custom rules from the filesystem. For the demo, a build step replaces the rule loader with static require()
calls so that ESLint and its built-in rules can be combined into a single package for the browser. I'd suggest starting there. If you can get it loaded in the browser, then you can use the Linter
API by passing it your string and a configuration object.
Upvotes: 4