Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Cleans up ESLint rules #5

Merged
merged 7 commits into from
Oct 31, 2022
Merged

Cleans up ESLint rules #5

merged 7 commits into from
Oct 31, 2022

Conversation

madsnedergaard
Copy link
Member

@madsnedergaard madsnedergaard commented Oct 26, 2022

Description

Changes from "all" to "recommended" for all plugins.
Adjusts some rules.
Also added the .vscode folder that was gitignored and a symlink so you can open both web and / in VSCode and still get the same settings.

TBD

There's some rules here about larger patterns we should discuss!

  1. Filenames Keep
    PascalCase for components, camelCase for everything else?
    (The is default in the starter, but we can do whatever)

  2. Declaring components Discuss
    It can be done in a bunch of different ways in JS. Should we enforce strictness around this?
    Starter uses react/function-component-definition: [“error”, {“namedComponents”: “function-declaration”}]which means this:

// incorrect (arrow function)
const CoolComponent = ({name}) => <div>{name}</div>

// correct
function CoolComponent({ name }) {
  return <div>{name}</div>;
}
  1. explicit-function-return-type Remove
// incorrect because it doesn't have a :boolean return type explicit
function isBoolean(value) {
  return true;
}
  1. type alias Discuss

  2. Absolute imports Prefix with ~
    To prefix imports or not?
    E.g. import X from @components/whatever vs import X from components/whatever
    If yes, use @ or ~?

Base automatically changed from mn/removes-stylelint to master October 27, 2022 12:02
@madsnedergaard madsnedergaard mentioned this pull request Oct 28, 2022
@tonypls
Copy link

tonypls commented Oct 28, 2022

These might be nice while we build:

   "@typescript-eslint/no-empty-interface": "off",
    "@typescript-eslint/no-empty-function": "off",
    ```

@madsnedergaard madsnedergaard marked this pull request as ready for review October 28, 2022 08:27
@tonypls
Copy link

tonypls commented Oct 28, 2022

Do you think it would be nice to document a style guide of sorts of these rules in the readme or similar?

@madsnedergaard
Copy link
Member Author

Do you think it would be nice to document a style guide of sorts of these rules in the readme or similar?

Hmm, I imagined that the rules would actually be the guide - as there's only one way to do things, and ESLint will tell you if you're doing it any other way 😉
With that said, https://linear.app/electricitymaps/issue/ELE-1361/[documentation]-code-standards should probably cover parts of this :)

@tonypls
Copy link

tonypls commented Oct 31, 2022

I'm okay with old function definitions for components if we all want 👍

@madsnedergaard
Copy link
Member Author

I'm okay with old function definitions for components if we all want 👍

Let's try it and be ready to change if we don't like it - should be very easy to refactor as ESLint can autofix it :)

@madsnedergaard madsnedergaard merged commit 36f1567 into master Oct 31, 2022
@madsnedergaard madsnedergaard deleted the mn/cleanup-linting-config branch October 31, 2022 10:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants