-
Notifications
You must be signed in to change notification settings - Fork 316
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
Simplify ESLint Config #261
Changes from all commits
3c0b758
d10255d
e2cdb52
e361168
dbc513c
6b6042e
4ac049c
15caf76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,135 @@ | ||
/** | ||
* This is intended to be a basic starting point for linting in the Indie Stack. | ||
* It relies on recommended configs out of the box for simplicity, but you can | ||
* and should modify this configuration to best suit your team's needs. | ||
*/ | ||
|
||
/** @type {import('eslint').Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
extends: [ | ||
"@remix-run/eslint-config", | ||
"@remix-run/eslint-config/node", | ||
"@remix-run/eslint-config/jest-testing-library", | ||
"prettier", | ||
], | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
env: { | ||
"cypress/globals": true, | ||
browser: true, | ||
commonjs: true, | ||
es6: true, | ||
}, | ||
plugins: ["cypress"], | ||
// we're using vitest which has a very similar API to jest | ||
// (so the linting plugins work nicely), but it means we have to explicitly | ||
// set the jest version. | ||
settings: { | ||
jest: { | ||
version: 28, | ||
|
||
// Base config | ||
extends: ["eslint:recommended"], | ||
|
||
overrides: [ | ||
// React | ||
{ | ||
files: ["**/*.{js,jsx,ts,tsx}"], | ||
plugins: ["react", "jsx-a11y"], | ||
extends: [ | ||
"plugin:react/recommended", | ||
"plugin:react/jsx-runtime", | ||
"plugin:jsx-a11y/recommended", | ||
"prettier", | ||
], | ||
settings: { | ||
react: { | ||
version: "detect", | ||
}, | ||
formComponents: ["Form"], | ||
linkComponents: [ | ||
{ name: "Link", linkAttribute: "to" }, | ||
{ name: "NavLink", linkAttribute: "to" }, | ||
], | ||
}, | ||
rules: { | ||
"react/jsx-no-leaked-render": [ | ||
"warn", | ||
{ validStrategies: ["ternary"] }, | ||
], | ||
}, | ||
}, | ||
}, | ||
|
||
// Typescript | ||
{ | ||
files: ["**/*.{ts,tsx}"], | ||
plugins: ["@typescript-eslint", "import"], | ||
parser: "@typescript-eslint/parser", | ||
settings: { | ||
"import/internal-regex": "^~/", | ||
"import/resolver": { | ||
node: { | ||
extensions: [".ts", ".tsx"], | ||
}, | ||
typescript: { | ||
alwaysTryTypes: true, | ||
}, | ||
}, | ||
}, | ||
extends: [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/stylistic", | ||
"plugin:import/recommended", | ||
"plugin:import/typescript", | ||
"prettier", | ||
], | ||
rules: { | ||
"import/order": [ | ||
"error", | ||
{ | ||
alphabetize: { caseInsensitive: true, order: "asc" }, | ||
groups: ["builtin", "external", "internal", "parent", "sibling"], | ||
"newlines-between": "always", | ||
}, | ||
], | ||
}, | ||
Comment on lines
+78
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. I personally hate lack of consistency when it comes to imports - but again this is veering into "opinion" territory. |
||
}, | ||
|
||
// Markdown | ||
{ | ||
files: ["**/*.md"], | ||
plugins: ["markdown"], | ||
extends: ["plugin:markdown/recommended", "prettier"], | ||
}, | ||
|
||
// Jest/Vitest | ||
{ | ||
files: ["**/*.test.{js,jsx,ts,tsx}"], | ||
plugins: ["jest", "jest-dom", "testing-library"], | ||
extends: [ | ||
"plugin:jest/recommended", | ||
"plugin:jest-dom/recommended", | ||
"plugin:testing-library/react", | ||
"prettier", | ||
], | ||
env: { | ||
"jest/globals": true, | ||
}, | ||
settings: { | ||
jest: { | ||
// we're using vitest which has a very similar API to jest | ||
// (so the linting plugins work nicely), but it means we have to explicitly | ||
// set the jest version. | ||
version: 28, | ||
}, | ||
}, | ||
}, | ||
|
||
// Cypress | ||
{ | ||
files: ["cypress/**/*.ts"], | ||
plugins: ["cypress"], | ||
extends: ["plugin:cypress/recommended", "prettier"], | ||
}, | ||
|
||
// Node | ||
{ | ||
files: [".eslintrc.js", "mocks/**/*.js"], | ||
env: { | ||
node: true, | ||
}, | ||
}, | ||
], | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ jobs: | |
run: npm install | ||
|
||
- name: 🔬 Lint | ||
run: npm run lint:repo | ||
run: npm run lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ export default function Join() { | |
ref={emailRef} | ||
id="email" | ||
required | ||
// eslint-disable-next-line jsx-a11y/no-autofocus | ||
autoFocus={true} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These feel like they're an OK exception to the rule as this form is the sole purpose of the page |
||
name="email" | ||
type="email" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { faker } from "@faker-js/faker"; | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know the best way to do this otherwise so I just disabled it. |
||
namespace Cypress { | ||
interface Chainable { | ||
/** | ||
|
@@ -85,7 +86,7 @@ function deleteUserByEmail(email: string) { | |
// Also added custom types to avoid getting detached | ||
// https://github.com/cypress-io/cypress/issues/7306#issuecomment-1152752612 | ||
// =========================================================== | ||
function visitAndCheck(url: string, waitTime: number = 1000) { | ||
function visitAndCheck(url: string, waitTime = 1000) { | ||
cy.visit(url); | ||
cy.location("pathname").should("contain", url).wait(waitTime); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way on this one-off rule. On one hand, if we truly want to stay out of the opinion game, then we technically should have zero
rules
or our own. But this one seems like it solves a common footgun, and TBH I was surprised it wasn't enable din the recommended plugin...so I added it. (It was also one we turned on viaeslintrc.repo.js
before.