chore: fix linting

Luke Karrys committed Oct 14, 2023 at 14:19 UTC 82da51ce273da9d5675042e80051e961326b00e3
15 files changed +75 -67
.eslintrc.js
+34 -13
@@ -1,21 +1,42 @@
1 -/* This file is automatically added by @npmcli/template-oss. Do not edit. */
2 -
3 -'use strict'
4 -
5 -const { readdirSync: readdir } = require('fs')
6 -
7 -const localConfigs = readdir(__dirname)
8 - .filter((file) => file.startsWith('.eslintrc.local.'))
9 - .map((file) => `./${file}`)
10 -
1 module.exports = {
2 root: true,
3 ignorePatterns: [
14 - 'cli/**',
15 - 'theme/**',
4 + 'cli/',
5 + 'theme/',
6 ],
7 extends: [
8 '@npmcli',
19 - ...localConfigs,
9 + 'eslint:recommended',
10 + 'plugin:react/recommended',
11 + 'plugin:github/react',
12 + 'plugin:primer-react/recommended',
13 + 'plugin:react-hooks/recommended',
14 ],
15 + settings: {
16 + react: {
17 + version: 'detect',
18 + },
19 + },
20 + overrides: [{
21 + files: ['src/**'],
22 + parserOptions: {
23 + ecmaFeatures: {
24 + jsx: true,
25 + },
26 + },
27 + env: {
28 + commonjs: true,
29 + es2022: true,
30 + browser: true,
31 + node: false,
32 + },
33 + rules: {
34 + 'max-len': 'off',
35 + },
36 + }, {
37 + files: ['src/shared.js'],
38 + rules: {
39 + 'react/no-unescaped-entities': 'off',
40 + },
41 + }],
42 }
.eslintrc.local.js deleted
-26
@@ -1,26 +0,0 @@
1 -module.exports = {
2 - extends: [
3 - 'plugin:github/react',
4 - 'plugin:primer-react/recommended',
5 - ],
6 - overrides: [{
7 - files: ['src/**'],
8 - parserOptions: {
9 - ecmaFeatures: {
10 - jsx: true,
11 - },
12 - sourceType: 'module',
13 - },
14 - env: {
15 - commonjs: true,
16 - es2022: true,
17 - browser: true,
18 - node: false,
19 - },
20 - rules: {
21 - 'max-len': 'off',
22 - 'import/no-extraneous-dependencies': 'off',
23 - 'no-unused-vars': 'off',
24 - },
25 - }],
26 -}
package-lock.json
+5
@@ -12,6 +12,7 @@
12 "theme/"
13 ],
14 "dependencies": {
15 + "@primer/react": "^35.31.0",
16 "gatsby": "^4.25.7",
17 "react": "^17.0.2",
18 "react-dom": "^17.0.2",
@@ -20,8 +21,12 @@
21 "devDependencies": {
22 "@npmcli/eslint-config": "^4.0.2",
23 "@npmcli/template-oss": "4.19.0",
24 + "eslint": "^8.51.0",
25 "eslint-plugin-github": "^4.10.1",
26 + "eslint-plugin-jsx-a11y": "^6.7.1",
27 "eslint-plugin-primer-react": "^4.0.3",
28 + "eslint-plugin-react": "^7.33.2",
29 + "eslint-plugin-react-hooks": "^4.6.0",
30 "tap": "^16.3.9"
31 },
32 "engines": {
package.json
+5
@@ -27,6 +27,7 @@
27 "theme/"
28 ],
29 "dependencies": {
30 + "@primer/react": "^35.31.0",
31 "gatsby": "^4.25.7",
32 "react": "^17.0.2",
33 "react-dom": "^17.0.2",
@@ -35,8 +36,12 @@
36 "devDependencies": {
37 "@npmcli/eslint-config": "^4.0.2",
38 "@npmcli/template-oss": "4.19.0",
39 + "eslint": "^8.51.0",
40 "eslint-plugin-github": "^4.10.1",
41 + "eslint-plugin-jsx-a11y": "^6.7.1",
42 "eslint-plugin-primer-react": "^4.0.3",
43 + "eslint-plugin-react": "^7.33.2",
44 + "eslint-plugin-react-hooks": "^4.6.0",
45 "tap": "^16.3.9"
46 },
47 "author": "GitHub Inc.",
scripts/template-oss/index.js
+1
@@ -11,6 +11,7 @@ module.exports = {
11 },
12 rootModule: {
13 add: {
14 + '.eslintrc.js': false,
15 'CODE_OF_CONDUCT.md': false,
16 'CONTRIBUTING.md': false,
17 },
src/pages/404.js new
+9
@@ -0,0 +1,9 @@
1 +import React from 'react'
2 +
3 +const Page404 = () => {
4 + return (
5 + <h1>404 page</h1>
6 + )
7 +}
8 +
9 +export default Page404
theme/.eslintrc.js
+2 -6
@@ -27,12 +27,8 @@ module.exports = {
27 rules: {
28 'max-len': 'off',
29 'react/prop-types': 'off',
30 - 'react/display-name': 'off',
31 - 'eslint-comments/no-use': 'off',
32 - 'no-shadow': 'off',
33 - 'primer-react/no-system-props': ['warn', {includeUtilityComponents: true}],
34 - 'import/no-commonjs': 'off',
35 - 'no-console': 'off',
30 + // TODO: migrate primer/react components to sx instead of deprecated system props
31 + 'primer-react/no-system-props': ['off', {includeUtilityComponents: true}],
32 },
33 overrides: [
34 {
theme/src/components/border-box.js
+3 -1
@@ -1,4 +1,6 @@
1 import React from 'react'
2 import {Box} from '@primer/react'
3
4 -export default props => <Box {...props} />
4 +const BorderBox = props => <Box {...props} />
5 +
6 +export default BorderBox
theme/src/components/code.js
+2 -2
@@ -39,8 +39,8 @@ const useScrollSize = () => {
39 return {scrollRef, paddingRef, size}
40 }
41
42 -function Code({className, children}) {
43 - const language = className ? className.replace(/language-/, '') : ''
42 +function Code({className: parentClass, children}) {
43 + const language = parentClass ? parentClass.replace(/language-/, '') : ''
44 const code = children.trim()
45 const {scrollRef, paddingRef, size} = useScrollSize()
46
theme/src/components/contributors.js
+1
@@ -29,6 +29,7 @@ function Contributors({logins, latestCommit}) {
29 </Text>
30 {logins.map(login => (
31 <Link key={login} href={`https://github.com/${login}`} lineHeight="condensedUltra" mr={2}>
32 + {/* eslint-disable-next-line primer-react/a11y-tooltip-interactive-trigger */}
33 <Tooltip key={login} aria-label={login}>
34 <Avatar src={`https://github.com/${login}.png?size=40`} alt={login} />
35 </Tooltip>
theme/src/components/flex.js
+3 -1
@@ -1,4 +1,6 @@
1 import React from 'react'
2 import {Box} from '@primer/react'
3
4 -export default props => <Box display="flex" {...props} />
4 +const Flex = props => <Box display="flex" {...props} />
5 +
6 +export default Flex
theme/src/components/variant-select.js
+4 -8
@@ -5,7 +5,7 @@
5 // then you'll get a selection for the different variants (v1.0, v2.0).
6
7 import React from 'react'
8 -import {ActionList, ActionMenu, ThemeProvider} from '@primer/react'
8 +import {ActionList, ActionMenu} from '@primer/react'
9 import NavHierarchy from '../util/nav-hierarchy'
10
11 function VariantSelect(props) {
@@ -55,13 +55,9 @@ function VariantSelect(props) {
55 )
56 }
57
58 - // const ariaLabelMenuButton = open ? 'Version release' : selectedItem.variant.title
59 -
58 return (
61 - <ThemeProvider>
62 - <p id="label-versions-list-item">
63 - Select CLI Version:
64 - </p>
59 + <>
60 + <p id="label-versions-list-item">Select CLI Version:</p>
61 <ActionMenu open={open} onOpenChange={setOpen}>
62 {/* Disabling to remove lint warnings. This property was added as "autofocus"
63 in a previous accessibility audit which did not trigger the lint warning. */
@@ -75,7 +71,7 @@ function VariantSelect(props) {
71 </ActionList>
72 </ActionMenu.Overlay>
73 </ActionMenu>
78 - </ThemeProvider>
74 + </>
75 )
76 }
77
theme/src/hooks/use-breakpoint.js
+1 -1
@@ -28,7 +28,7 @@ export function useBreakpoint(breakpoint, minMax = 'min') {
28
29 // a common breakpoint where things change on mobile
30 export function useIsMobile() {
31 - const theme = useTheme()
31 + const {theme} = useTheme()
32 return useBreakpoint(theme.breakpoints[2], 'max')
33 }
34
theme/src/hooks/use-search.js
+3 -7
@@ -25,10 +25,6 @@ const useSearchData = () => {
25 `)
26
27 return React.useMemo(() => {
28 - if (!rawData) {
29 - return [{path: '/', title: 'Dev Title', rawBody: 'Test'}]
30 - }
31 -
28 const mdxNodes = rawData.allMdx.nodes.reduce((map, obj) => {
29 map[obj.id] = obj
30 return map
@@ -58,7 +54,7 @@ function useSearch() {
54 const [query, setQuery] = React.useState()
55 const [items, setItems] = React.useState(null)
56
61 - const data = useSearchData()
57 + const searchData = useSearchData()
58
59 const handleSearchResults = React.useCallback(({data}) => {
60 if (data.query && data.results && data.query === queryRef.current) {
@@ -71,10 +67,10 @@ function useSearch() {
67 workerRef.current = worker
68
69 worker.addEventListener('message', handleSearchResults)
74 - worker.postMessage({data})
70 + worker.postMessage({data: searchData})
71
72 return () => worker.terminate()
77 - }, [data, handleSearchResults])
73 + }, [searchData, handleSearchResults])
74
75 React.useEffect(() => {
76 queryRef.current = query
theme/src/util/nav-hierarchy.js
+2 -2
@@ -223,8 +223,8 @@ export default {
223 variantPage = variant
224 } else {
225 variantPage = this.findItem(item => {
226 - const vp = this.getVariantAndPage(root, item.url)
227 - return vp && vp.page === page ? item : null
226 + const itemVp = this.getVariantAndPage(root, item.url)
227 + return itemVp && itemVp.page === page ? item : null
228 }, variant.children)
229 }
230