-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add import and style sorting config + capabilities. #132
Changes from 3 commits
2ac3cf7
d1c302c
701f868
3a5640c
6454106
8f0427e
8e71ee1
eb96a28
f7013b5
5180ec4
3847275
a48d963
e073215
f0d780b
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 |
---|---|---|
|
@@ -3,9 +3,11 @@ const config = { | |
extends: ["next/core-web-vitals", "plugin:@typescript-eslint/recommended", "prettier"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "./tsconfig.json", | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
project: "./tsconfig.json", | ||
"sourceType": "module", | ||
"ecmaVersion": "latest", | ||
}, | ||
plugins: ["@typescript-eslint", "simple-import-sort"], | ||
root: true, | ||
ignorePatterns: ["node_modules", "src/hooks/useScrollBox.ts"], | ||
rules: { | ||
|
@@ -26,6 +28,31 @@ const config = { | |
caughtErrorsIgnorePattern: "^_", | ||
}, | ||
], | ||
"import/first": "error", | ||
"import/newline-after-import": "error", | ||
"import/no-duplicates": "error", | ||
"simple-import-sort/imports": [ | ||
"error", | ||
{ | ||
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. Weird alignment, is this not caught by the formatter? |
||
"groups": [ | ||
// Packages. `react` related packages come first. | ||
[ | ||
"^react", | ||
"^next", | ||
], | ||
// Internal packages. | ||
["^@?\\w"], | ||
// Parent imports. Put `..` last. | ||
["^\\.\\.(?!/?$)", "^\\.\\./?$"], | ||
// Other relative imports. Put same-folder imports and `.` last. | ||
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"], | ||
// Style imports. | ||
["^.+\\.s?css$"], | ||
// Side effect imports. | ||
["^\\u0000"] | ||
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. One rule that would be great is to make sure the internal imports, which we prefix with |
||
] | ||
} | ||
] | ||
}, | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"javascript.validate.enable": false, | ||
"typescript.validate.enable": false | ||
"typescript.validate.enable": false, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import React from "react" | ||
import { CardPlacement } from "src/store/types" | ||
|
||
import { useSortable } from "@dnd-kit/sortable" | ||
import DraggedCard from "./draggedCard" | ||
import BoardCard from "./boardCard" | ||
import HandCard from "./handCard" | ||
import { CSS } from "@dnd-kit/utilities" | ||
import { CardPlacement } from "src/store/types" | ||
import { convertStringToSafeNumber } from "src/utils/js-utils" | ||
|
||
import BoardCard from "./boardCard" | ||
import DraggedCard from "./draggedCard" | ||
import HandCard from "./handCard" | ||
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 should use the I think we could use this type of rule to prevent them, but I wonder if we'd need to be able to make exception to import files form other packages (e.g. deployment addresses) — I think we could get around that by copying files however. Could you look into it? 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. added this rule, running |
||
|
||
interface BaseCardProps { | ||
id: string | ||
className?: string | ||
|
@@ -49,7 +51,7 @@ const CardContainer: React.FC<BaseCardProps> = ({ id, handHovered, placement, ca | |
} | ||
return ( | ||
<div | ||
className={`${"shadow-2xl z-[50] flex max-w-[24rem] cursor-pointer flex-col items-center justify-evenly rounded-lg bg-gray-900 transform translateY-[-50%]"}`} | ||
className={`${"translateY-[-50%] z-[50] flex max-w-[24rem] transform cursor-pointer flex-col items-center justify-evenly rounded-lg bg-gray-900 shadow-2xl"}`} | ||
style={sortableStyle} | ||
ref={setNodeRef} | ||
{...attributes} | ||
|
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.
What's with the weird indentation here?
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.
It doesn't seem to appear on my local repo. 😶
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.
It's because of mixed tabs and spaces. We should add
.cjs
and.mjs
files to the list of those who get formatted by prettier, cand you do that?