google / gts

☂️ TypeScript style guide, formatter, and linter.
https://github.com/google/gts
Apache License 2.0
5.09k stars 206 forks source link

Support for non-node environments #884

Open libkakashi opened 5 months ago

libkakashi commented 5 months ago

As of now, the default .eslintrc.json file that's extended by all projects has the following code:

{
  "extends": [
    "eslint:recommended",
    "plugin:node/recommended",
    "prettier"
  ],
  "plugins": [
    "node",
    "prettier"
  ],
  ...
}

Overwriting this to make it work with browser envs, bun, figma plugins, etc. is bit of a pain. Could we have something like a CLI flag that makes it optional to include node specific rules?

tonycoco commented 5 months ago

Great idea. Can you provide me a diff for what makes it hard to work on a Figma plugin or something else? Also happy to check a PR on the flag if you are interested in adding this feature.

libkakashi commented 5 months ago

Sure, I could probably work on it sometime over the weekend

One example is how imports don't work in js files even when not using node. Let's say I've a simple js file like this:

import script2 from './script2.js';

document.getElementById('button').addEventListener('click', () => {
  console.log('button clicked');
  script2();
});

I'd get an error saying error Import and export declarations are not supported yet, unless I mention "n/no-unsupported-features/es-syntax": "off" in my eslint config, even tho I'm not using node at all.