Skip to content

Commit d573dd1

Browse files
dgreifcolebemis
andauthored
Eslint all files with prettier (#1145)
Co-authored-by: Cole Bemis <colebemis@github.com>
1 parent a469b85 commit d573dd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+603
-495
lines changed

.eslintrc.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"extends": ["plugin:react/recommended", "plugin:jsx-a11y/recommended", "plugin:react-hooks/recommended"],
3+
"parserOptions": {
4+
"ecmaFeatures": {
5+
"jsx": true
6+
}
7+
},
8+
"extends": [
9+
"plugin:react/recommended",
10+
"plugin:jsx-a11y/recommended",
11+
"plugin:react-hooks/recommended",
12+
"plugin:prettier/recommended"
13+
],
14+
"ignorePatterns": [
15+
"node_modules",
16+
".cache",
17+
"coverage/**/*",
18+
"docs/public/**/*",
19+
"dist/**/*",
20+
"lib/**/*",
21+
"lib-*/**/*",
22+
"types/**/*"
23+
],
424
"globals": {
525
"__DEV__": "readonly"
626
},
@@ -38,7 +58,12 @@
3858
// rules which apply only to TS
3959
{
4060
"files": ["**/*.ts", "**/*.tsx"],
41-
"extends": ["plugin:@typescript-eslint/recommended"]
61+
"extends": ["plugin:@typescript-eslint/recommended"],
62+
"rules": {
63+
"@typescript-eslint/no-explicit-any": 0,
64+
"@typescript-eslint/explicit-module-boundary-types": 0,
65+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
66+
}
4267
}
4368
]
4469
}

codemods/lib/modifyProps.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
module.exports = (ast, j, moduleName, propsMap) => {
22
const importsByName = {}
33

4-
ast.find(j.ImportDeclaration, decl => decl.source.value === moduleName).forEach(decl => {
5-
j(decl)
6-
.find(j.ImportSpecifier)
7-
.forEach(spec => {
8-
importsByName[spec.node.imported.name] = spec.node.local.name
9-
})
10-
})
4+
ast
5+
.find(j.ImportDeclaration, decl => decl.source.value === moduleName)
6+
.forEach(decl => {
7+
j(decl)
8+
.find(j.ImportSpecifier)
9+
.forEach(spec => {
10+
importsByName[spec.node.imported.name] = spec.node.local.name
11+
})
12+
})
1113

1214
ast
1315
.find(j.JSXElement, {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = function replaceImportSource(ast, j, from, to) {
2-
ast.find(j.ImportDeclaration, decl => decl.source.value === from).forEach(decl => {
3-
j(decl)
4-
.find(j.Literal, {value: from})
5-
.replaceWith(j.literal(to))
6-
})
2+
ast
3+
.find(j.ImportDeclaration, decl => decl.source.value === from)
4+
.forEach(decl => {
5+
j(decl).find(j.Literal, {value: from}).replaceWith(j.literal(to))
6+
})
77
}

docs/gatsby-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ module.exports = {
1313
options: {
1414
repoRootPath: '..',
1515
defaultBranch: 'main'
16-
},
16+
}
1717
},
1818
{
1919
resolve: `gatsby-plugin-alias-imports`,
2020
options: {
2121
alias: {
2222
'@primer/components': path.resolve(__dirname, '../src'),
2323
'styled-components': path.resolve(__dirname, '..', 'node_modules', 'styled-components'),
24-
'react': path.resolve(__dirname, 'node_modules', 'react'),
24+
react: path.resolve(__dirname, 'node_modules', 'react')
2525
}
2626
}
2727
}

docs/gatsby-node.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ exports.onCreateWebpackConfig = ({actions, plugins, loaders, getConfig}) => {
1212
// The new configuration is based off the original...
1313
...loaders.js(),
1414
test: /\.jsx?$/,
15-
exclude: (modulePath) => /node_modules/.test(modulePath),
15+
exclude: modulePath => /node_modules/.test(modulePath),
1616
// ...except that we want to run Primer React through webpack as well.
1717
// By default, Gatsby won't use the define plugin we added above on Primer React.
18-
include: (modulePath) => /@primer\/components/.test(modulePath),
19-
},
18+
include: modulePath => /@primer\/components/.test(modulePath)
19+
}
2020
]
2121
actions.replaceWebpackConfig(config)
2222
}

index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-empty-interface */
12
declare module '@primer/components' {
23
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>
34
import * as StyledSystem from 'styled-system'
4-
import {SystemStyleObject} from '@styled-system/css'
5-
import * as StyledComponents from 'styled-components'
65
import {ReactComponentLike} from 'prop-types'
76
import * as History from 'history'
87

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"dist:transpile:cjs": "rm -rf lib && cross-env BABEL_MODULE=commonjs babel src --out-dir lib --extensions '.js,.ts,.jsx,.tsx'",
1313
"dist:transpile:esm": "rm -rf lib-esm && babel src --out-dir lib-esm --extensions '.js,.ts,.jsx,.tsx'",
1414
"dist:types": "rm -rf types && tsc",
15-
"lint": "eslint src docs/components",
15+
"lint": "eslint '**/*.{js,ts,tsx}'",
16+
"lint:fix": "eslint '**/*.{js,ts,tsx}' --fix",
1617
"test": "jest -- src",
1718
"update-snapshots": "jest -u -- src",
1819
"watch": "jest --watch --no-coverage",
@@ -61,7 +62,7 @@
6162
"devDependencies": {
6263
"@babel/cli": "7.8.4",
6364
"@babel/core": "7.9.0",
64-
"@babel/eslint-parser": "7.12.1",
65+
"@babel/eslint-parser": "7.13.14",
6566
"@babel/plugin-proposal-nullish-coalescing-operator": "7.12.1",
6667
"@babel/plugin-proposal-optional-chaining": "7.12.16",
6768
"@babel/plugin-transform-modules-commonjs": "7.12.1",
@@ -86,8 +87,8 @@
8687
"@types/jest-axe": "3.5.1",
8788
"@types/lodash.isempty": "4.4.6",
8889
"@types/lodash.isobject": "3.0.6",
89-
"@typescript-eslint/eslint-plugin": "4.14.1",
90-
"@typescript-eslint/parser": "4.14.1",
90+
"@typescript-eslint/eslint-plugin": "4.20.0",
91+
"@typescript-eslint/parser": "4.20.0",
9192
"@wojtekmaj/enzyme-adapter-react-17": "0.3.2",
9293
"babel-core": "7.0.0-bridge.0",
9394
"babel-loader": "^8.2.2",
@@ -101,20 +102,21 @@
101102
"concurrently": "5.3.0",
102103
"cross-env": "7.0.2",
103104
"enzyme": "3.10.0",
104-
"eslint": "6.5.1",
105-
"eslint-plugin-github": "4.1.1",
106-
"eslint-plugin-jest": "22.20.0",
107-
"eslint-plugin-jsx-a11y": "6.2.3",
105+
"eslint": "7.23.0",
106+
"eslint-plugin-github": "4.1.2",
107+
"eslint-plugin-jest": "24.3.2",
108+
"eslint-plugin-jsx-a11y": "6.4.1",
108109
"eslint-plugin-prettier": "3.3.1",
109-
"eslint-plugin-react": "7.22.0",
110-
"eslint-plugin-react-hooks": "3.0.0",
110+
"eslint-plugin-react": "7.23.1",
111+
"eslint-plugin-react-hooks": "4.2.0",
111112
"jest": "26.6.3",
112113
"jest-axe": "4.1.0",
113114
"jest-styled-components": "6.3.3",
114115
"jscodeshift": "0.6.4",
115116
"lodash.isempty": "4.4.0",
116117
"lodash.isobject": "3.0.2",
117118
"playroom": "0.15.1",
119+
"prettier": "2.2.1",
118120
"react": "^17.0.0",
119121
"react-dom": "^17.0.0",
120122
"react-test-renderer": "16.10.2",

src/Button/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ export {default as ButtonTableList} from './ButtonTableList'
1414
export type {ButtonTableListProps} from './ButtonTableList'
1515
export {default as ButtonClose} from './ButtonClose'
1616
export type {ButtonCloseProps} from './ButtonClose'
17-

src/Link.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ type StyledLinkProps = {
1212
SxProp &
1313
SystemTypographyProps
1414

15-
const buttonStyles = `
16-
display: inline-block;
17-
padding: 0;
18-
font-size: inherit;
19-
white-space: nowrap;
20-
cursor: pointer;
21-
user-select: none;
22-
background-color: transparent;
23-
border: 0;
24-
appearance: none;
25-
`
26-
2715
const hoverColor = system({
2816
hoverColor: {
2917
property: 'color',

src/Pagination/Pagination.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const Page = styled.a`
108108
`
109109

110110
type UsePaginationPagesParameters = {
111-
theme?: object // set to theme type once /src/theme.js is converted
111+
theme?: Record<string, unknown> // set to theme type once /src/theme.js is converted
112112
pageCount: number
113113
currentPage: number
114114
onPageChange: (e: React.MouseEvent, n: number) => void
@@ -156,7 +156,7 @@ const PaginationContainer = styled.nav`
156156
`
157157

158158
export type PaginationProps = {
159-
theme?: object
159+
theme?: Record<string, unknown>
160160
pageCount: number
161161
currentPage: number
162162
onPageChange?: (e: React.MouseEvent, n: number) => void
@@ -200,6 +200,7 @@ function defaultHrefBuilder(pageNum: number) {
200200
return `#${pageNum}`
201201
}
202202

203+
// eslint-disable-next-line @typescript-eslint/no-empty-function
203204
function noop() {}
204205

205206
Pagination.defaultProps = {

0 commit comments

Comments
 (0)