Skip to content

Commit 6123468

Browse files
committed
Add ESLint plugins for next and import sort order
1 parent d8c35af commit 6123468

21 files changed

+111
-54
lines changed

.eslintrc

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2-
"extends": ["plugin:react/recommended", "plugin:@typescript-eslint/recommended"],
3-
"plugins": ["@typescript-eslint", "react-hooks"],
2+
"extends": [
3+
"plugin:react/recommended",
4+
"plugin:@typescript-eslint/recommended",
5+
"plugin:@next/next/recommended",
6+
"plugin:import/recommended",
7+
"plugin:import/typescript"
8+
],
9+
"plugins": ["@typescript-eslint", "react-hooks", "import"],
410
"parser": "@typescript-eslint/parser",
511
"parserOptions": {
612
"ecmaVersion": 2018,
@@ -24,6 +30,53 @@
2430
"@typescript-eslint/no-empty-interface": "off",
2531
"@typescript-eslint/ban-types": "off",
2632
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
27-
"@typescript-eslint/no-inferrable-types": "off"
33+
"@typescript-eslint/no-inferrable-types": "off",
34+
"import/order": [
35+
"error",
36+
{
37+
"groups": [
38+
"builtin",
39+
"external",
40+
"internal",
41+
"type",
42+
"parent",
43+
"sibling",
44+
"index",
45+
"object"
46+
],
47+
"pathGroups": [
48+
{
49+
"pattern": "next/*",
50+
"group": "builtin",
51+
"position": "before"
52+
},
53+
{
54+
"pattern": "next",
55+
"group": "builtin",
56+
"position": "before"
57+
},
58+
{
59+
"pattern": "react-*",
60+
"group": "builtin",
61+
"position": "before"
62+
},
63+
{
64+
"pattern": "react-*/*",
65+
"group": "builtin",
66+
"position": "before"
67+
},
68+
{
69+
"pattern": "react",
70+
"group": "builtin",
71+
"position": "before"
72+
}
73+
],
74+
"pathGroupsExcludedImportTypes": ["react", "next"],
75+
"alphabetize": {
76+
"order": "asc",
77+
"caseInsensitive": true
78+
}
79+
}
80+
]
2881
}
2982
}

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
"build": "cross-env IS_BUILD=true next build",
1111
"start": "next start",
1212
"lint": "next lint",
13+
"lint:fix": "npm run lint -- --fix",
1314
"format": "prettier \"src/**/*.{ts,tsx}\" --write",
14-
"typecheck": "tsc",
15-
"pretest": "npm run format",
16-
"test": "npm run lint && npm run typecheck"
15+
"format:check": "npm run format -- --check",
16+
"typescript": "tsc",
17+
"test": "npm run format:check && npm run lint:fix && npm run typescript"
1718
},
1819
"dependencies": {
1920
"@octokit/graphql": "^4.6.4",
@@ -39,6 +40,7 @@
3940
"cross-env": "^7.0.3",
4041
"eslint": "7.31.0",
4142
"eslint-config-next": "11.0.1",
43+
"eslint-plugin-import": "^2.25.3",
4244
"eslint-plugin-react": "^7.27.0",
4345
"eslint-plugin-react-hooks": "^4.3.0",
4446
"prettier": "^2.3.2",

src/components/champions/ChampionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ChampionCard } from '.'
21
import { SimplifiedChampion } from '../../types'
2+
import { ChampionCard } from '.'
33

44
interface Props {
55
champions: SimplifiedChampion[]

src/components/common/SearchBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChangeEvent, FC, KeyboardEventHandler, memo, useCallback, useRef } from 'react'
2-
import styled from 'styled-components'
32
import { FiSearch as SearchIcon, FiX as ClearSearchIcon } from 'react-icons/fi'
3+
import styled from 'styled-components'
44
import { debounce } from '../../utils/debounce'
55

66
const Container = styled.div<{ width: string }>`

src/components/common/layout/Header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { useCallback, useEffect, useState } from 'react'
2+
import { GoThreeBars as MenuIcon, GoX as CloseIcon } from 'react-icons/go'
13
import Link from 'next/link'
4+
import { useRouter } from 'next/router'
25
import styled from 'styled-components'
3-
import { GoThreeBars as MenuIcon, GoX as CloseIcon } from 'react-icons/go'
4-
import { Logo } from '../Logo'
56
import { useMediaQuery } from '../../../hooks/useMediaQuery'
6-
import { useCallback, useEffect, useState } from 'react'
7+
import { Logo } from '../Logo'
78
import { Navigation } from './Navigation'
8-
import { useRouter } from 'next/router'
99

1010
const StyledHeader = styled.header`
1111
background: var(--header-color);

src/components/common/layout/Navigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { useRouter } from 'next/router'
1+
import { FaSun, FaMoon } from 'react-icons/fa'
22
import Link from 'next/link'
3+
import { useRouter } from 'next/router'
34
import styled from 'styled-components'
4-
import { FaSun, FaMoon } from 'react-icons/fa'
55
import { useTheme } from '../../../hooks/useTheme'
66

77
const Nav = styled.nav`

src/components/proposals/DetailsExpander.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Link from 'next/link'
22
import styled from 'styled-components'
3-
import { SanitizedHtml, Heading } from '../common'
4-
import { StarIcon } from '../common/StarIcon'
5-
import { GitHubIcon } from '../common/GitHubIcon'
6-
import { formatStageName } from '../../utils/formatStageName'
73
import { Proposal } from '../../types'
4+
import { formatStageName } from '../../utils/formatStageName'
85
import { getGitHubDetails, isGithubProposal } from '../../utils/github'
6+
import { SanitizedHtml, Heading } from '../common'
97
import { Expander } from '../common/Expander'
8+
import { GitHubIcon } from '../common/GitHubIcon'
9+
import { StarIcon } from '../common/StarIcon'
1010

1111
const DetailCard = styled.div`
1212
display: flex;

src/components/proposals/DetailsSidebar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Link from 'next/link'
22
import styled from 'styled-components'
3-
import { SanitizedHtml, Heading } from '../common'
4-
import { StarIcon } from '../common/StarIcon'
5-
import { GitHubIcon } from '../common/GitHubIcon'
6-
import { formatStageName } from '../../utils/formatStageName'
73
import { Proposal } from '../../types'
4+
import { formatStageName } from '../../utils/formatStageName'
85
import { getGitHubDetails, isGithubProposal } from '../../utils/github'
6+
import { SanitizedHtml, Heading } from '../common'
7+
import { GitHubIcon } from '../common/GitHubIcon'
8+
import { StarIcon } from '../common/StarIcon'
99

1010
const Sidebar = styled.aside`
1111
display: flex;

src/components/proposals/ProposalCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { FC, memo } from 'react'
12
import Link from 'next/link'
23
import styled from 'styled-components'
3-
import { SanitizedHtml } from '../common/SanitizedHtml'
44
import { Proposal, Stage } from '../../types'
5+
import { SanitizedHtml } from '../common/SanitizedHtml'
56
import { StarIcon } from '../common/StarIcon'
6-
import { FC, memo } from 'react'
77

88
const CardLink = styled.a`
99
color: var(--foreground);

src/components/proposals/ProposalList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { FiEdit2 as PenIcon } from 'react-icons/fi'
2+
import { IoRibbonSharp as AwardIcon } from 'react-icons/io5'
13
import Link from 'next/link'
24
import styled from 'styled-components'
3-
import { SanitizedHtml } from '../common/SanitizedHtml'
4-
import { IoRibbonSharp as AwardIcon } from 'react-icons/io5'
5-
import { FiEdit2 as PenIcon } from 'react-icons/fi'
6-
import { StarIcon } from '../common/StarIcon'
75
import { ChampionedProposal } from '../../api/getAllChampions'
86
import { useMediaQuery } from '../../hooks/useMediaQuery'
7+
import { SanitizedHtml } from '../common/SanitizedHtml'
8+
import { StarIcon } from '../common/StarIcon'
99

1010
const Badges = styled.div`
1111
display: flex;

0 commit comments

Comments
 (0)