google / gts

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

Support for non-node environments #884

Open libkakashi opened 1 month ago

libkakashi commented 1 month 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 1 month 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 1 month 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.