Skip to content

Commit a9ece1b

Browse files
committed
feat(tslint): adopt eslint & fix issues it raised
TSlint is deprecated, no reason to keep using it
1 parent 9d7e7b3 commit a9ece1b

File tree

7 files changed

+791
-166
lines changed

7 files changed

+791
-166
lines changed

.eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
parserOptions: {
4+
jsx: true,
5+
},
6+
plugins: ["react", "@typescript-eslint", "jsx-a11y"],
7+
extends: [
8+
"eslint:recommended",
9+
"plugin:react/recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:jsx-a11y/recommended",
12+
],
13+
settings: {
14+
react: {
15+
pragma: "React",
16+
version: "detect",
17+
},
18+
},
19+
rules: {
20+
"@typescript-eslint/no-non-null-assertion": "off",
21+
"react/prop-types": "off",
22+
},
23+
};

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"test:coverage": "jest --coverage",
1414
"test:coverage:watch": "jest --coverage --watch",
1515
"coveralls": "cat ./coverage/lcov.info | coveralls",
16-
"lint": "tslint --project .",
16+
"lint": "eslint src",
1717
"typecheck": "tsc --project .",
1818
"build": "rimraf \"dist/**/*\" && yarn build:rollup && yarn build:types && yarn build:css",
1919
"build:css": "cp src/css/*.css dist",
@@ -95,11 +95,16 @@
9595
"@types/react-dom": "^16.8.4",
9696
"@types/react-test-renderer": "^16.8.2",
9797
"@types/uuid": "^3.4.4",
98+
"@typescript-eslint/eslint-plugin": "^3.6.0",
99+
"@typescript-eslint/parser": "^3.6.0",
98100
"babel-core": "^7.0.0-bridge.0",
99101
"babel-jest": "^24.8.0",
100102
"babel-loader": "^8.0.6",
101103
"coveralls": "^3.0.3",
102104
"css-loader": "^3.0.0",
105+
"eslint": "^7.4.0",
106+
"eslint-plugin-jsx-a11y": "^6.3.1",
107+
"eslint-plugin-react": "^7.20.3",
103108
"file-loader": "^4.0.0",
104109
"gh-pages": "^2.0.1",
105110
"html-webpack-plugin": "^3.2.0",
@@ -119,11 +124,6 @@
119124
"rollup-plugin-node-resolve": "^5.1.0",
120125
"rollup-plugin-replace": "^2.1.1",
121126
"style-loader": "^0.23.1",
122-
"tslint": "^6.1.2",
123-
"tslint-config-prettier": "^1.18.0",
124-
"tslint-microsoft-contrib": "^6.2.0",
125-
"tslint-plugin-prettier": "^2.3.0",
126-
"tslint-react": "^5.0.0",
127127
"typescript": "^3.9.5",
128128
"uuid": "^3.3.2",
129129
"webpack": "^4.29.6",

src/components/AccordionItemButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ const AccordionItemButton = ({
7373
<div
7474
className={className}
7575
{...rest}
76-
// tslint:disable-next-line react-a11y-event-has-role
76+
role="button"
77+
tabIndex={0}
7778
onClick={toggleExpanded}
7879
onKeyDown={handleKeyPress}
7980
data-accordion-component="AccordionItemButton"

src/components/ItemContext.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ class Provider extends React.Component<ProviderProps> {
6969
headingAttributes,
7070
buttonAttributes,
7171
}}
72-
children={this.props.children}
73-
/>
72+
>
73+
{this.props.children}
74+
</Context.Provider>
7475
);
7576
};
7677

src/helpers/uuid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export function resetNextUuid(): void {
1717

1818
// HTML5 ids allow all unicode characters, except for ASCII whitespaces
1919
// https://infra.spec.whatwg.org/#ascii-whitespace
20+
// eslint-disable-next-line no-control-regex
2021
const idRegex = /[\u0009\u000a\u000c\u000d\u0020]/g;
2122

2223
export function assertValidHtmlId(htmlId: string): boolean {
2324
if (htmlId === '' || idRegex.test(htmlId)) {
24-
// tslint:disable-next-line
2525
console.error(
2626
`uuid must be a valid HTML5 id but was given "${htmlId}", ASCII whitespaces are forbidden`,
2727
);

tslint.json

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)