Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit 159523f

Browse files
committed
Setting up eslint and jest
1 parent 6567d8a commit 159523f

31 files changed

+17636
-2957
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
src/clients/*.ts
4+
src/**/*.spec.js

.eslintrc.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'airbnb',
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/eslint-recommended',
7+
'plugin:@typescript-eslint/recommended'
8+
],
9+
plugins: [
10+
'@typescript-eslint',
11+
'import',
12+
'typescript',
13+
'prettier',
14+
'react'
15+
],
16+
parser: '@typescript-eslint/parser',
17+
parserOptions: {
18+
project: 'tsconfig.json',
19+
"ecmaVersion": 11,
20+
"sourceType": "module",
21+
"ecmaFeatures": {
22+
"jsx": true,
23+
"modules": true
24+
}
25+
},
26+
env: {
27+
browser: true,
28+
es6: true,
29+
jquery: true,
30+
jest: true,
31+
node: true,
32+
},
33+
globals: {
34+
"Atomics": "readonly",
35+
"SharedArrayBuffer": "readonly"
36+
},
37+
settings: {
38+
'import/resolver': {
39+
parcel: {
40+
extensions: ['.tsx', '.ts', '.js', '.jsx'],
41+
},
42+
},
43+
},
44+
rules: {
45+
'react/jsx-filename-extension': [1, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
46+
'import/extensions': 0,
47+
'react/jsx-indent': 0,
48+
'object-curly-newline' : 0,
49+
'no-trailing-spaces': 0,
50+
'no-multiple-empty-lines': 0,
51+
'operator-linebreak': 0,
52+
'indent': 0,
53+
'react/jsx-closing-tag-location': 0,
54+
'prettier/prettier': [ // customizing prettier rules (unfortunately not many of them are customizable)
55+
'error',
56+
{
57+
singleQuote: true,
58+
trailingComma: 'all',
59+
},
60+
],
61+
},
62+
};

babel.config.js

-3
This file was deleted.

babel.config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react']
3+
}

eslintrc.js

-13
This file was deleted.

jest.config.js

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1+
// jest.config.js
2+
const { defaults } = require('jest-config');
3+
14
module.exports = {
2-
preset: 'ts-jest',
3-
testEnvironment: 'node',
4-
};
5+
globals: {
6+
'ts-jest': {
7+
tsConfig: 'tsconfig.json',
8+
babelConfig: 'babel.config.json'
9+
}
10+
},
11+
preset: "ts-jest",
12+
roots: [
13+
"<rootDir>/src"
14+
],
15+
collectCoverage: true,
16+
collectCoverageFrom: [
17+
"**/*.{ts,tsx}",
18+
"!**/dist/**",
19+
"!**/node_modules/**"
20+
],
21+
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
22+
transform: {
23+
"^.+\\.(ts|tsx)$": "ts-jest"
24+
},
25+
testEnvironment: "node",
26+
testMatch: [
27+
"**/__tests__/**/*.+(ts|tsx|js)",
28+
"**/?(*.)+(spec|test).+(ts|tsx|js)"
29+
],
30+
};

lint.output

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
yarn run v1.22.4
2+
$ node ./node_modules/eslint/bin/eslint . --ext .jsx,.js,.ts,.tsx --fix
3+
4+
/Users/dougr/git_code/webos-streams/src/components/App.tsx
5+
40:13 error Unused state field: 'activeTab' react/no-unused-state
6+
51:15 error Unused state field: 'activeTab' react/no-unused-state
7+
66:20 error Identifier 'profile_image_url' is not in camel case camelcase
8+
66:39 error Identifier 'display_name' is not in camel case camelcase
9+
76:15 error Unused state field: 'activeTab' react/no-unused-state
10+
88:7 error JSX not allowed in files with extension '.tsx' react/jsx-filename-extension
11+
90:65 error JSX props should not use .bind() react/jsx-no-bind
12+
91:59 error JSX props should not use .bind() react/jsx-no-bind
13+
93:71 error JSX props should not use .bind() react/jsx-no-bind
14+
15+
/Users/dougr/git_code/webos-streams/src/components/ClipsPlayer.tsx
16+
4:20 error Unable to resolve path to module '../index' import/no-unresolved
17+
4:20 error Missing file extension for "../index" import/extensions
18+
23:7 error Visible, non-interactive elements with click handlers must have at least one keyboard listener jsx-a11y/click-events-have-key-events
19+
23:7 error Static HTML elements with event handlers require a role jsx-a11y/no-static-element-interactions
20+
23:7 error JSX not allowed in files with extension '.tsx' react/jsx-filename-extension
21+
24:9 error <iframe> elements must have a unique title property jsx-a11y/iframe-has-title
22+
23+
/Users/dougr/git_code/webos-streams/src/components/ClipsTab.tsx
24+
22:3 error loadClips should be placed after onKeyPress react/sort-comp
25+
82:40 error JSX props should not use .bind() react/jsx-no-bind
26+
82:68 error JSX props should not use .bind() react/jsx-no-bind
27+
87:7 error Visible, non-interactive elements with click handlers must have at least one keyboard listener jsx-a11y/click-events-have-key-events
28+
87:7 error Static HTML elements with event handlers require a role jsx-a11y/no-static-element-interactions
29+
87:7 error Anchor used as a button. Anchors are primarily expected to navigate. Use the button element instead. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
30+
88:9 error img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
31+
32+
/Users/dougr/git_code/webos-streams/src/components/NavBar.tsx
33+
23:9 error img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
34+
35+
/Users/dougr/git_code/webos-streams/src/components/NavHeader.tsx
36+
18:9 error Visible, non-interactive elements with click handlers must have at least one keyboard listener jsx-a11y/click-events-have-key-events
37+
18:9 error Static HTML elements with event handlers require a role jsx-a11y/no-static-element-interactions
38+
18:9 error Anchor used as a button. Anchors are primarily expected to navigate. Use the button element instead. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
39+
40+
/Users/dougr/git_code/webos-streams/src/components/SearchBar.tsx
41+
34:9 error Missing an explicit type attribute for button react/button-has-type
42+
43+
/Users/dougr/git_code/webos-streams/src/components/StreamTab.tsx
44+
11:1 error This line has a length of 120. Maximum allowed is 100 max-len
45+
19:15 error Expected 'this' to be used by class method 'removePlayer' class-methods-use-this
46+
47+
/Users/dougr/git_code/webos-streams/src/components/TabsContainer.tsx
48+
33:21 error Must use destructuring state assignment react/destructuring-assignment
49+
33:40 error Must use destructuring state assignment react/destructuring-assignment
50+
35:20 error Must use destructuring state assignment react/destructuring-assignment
51+
92:9 error JSX not allowed in files with extension '.tsx' react/jsx-filename-extension
52+
53+
/Users/dougr/git_code/webos-streams/src/components/VideosTab.tsx
54+
21:3 error loadVideos should be placed after getVideosCallback react/sort-comp
55+
57:14 error JSX not allowed in files with extension '.tsx' react/jsx-filename-extension
56+
61:7 error Visible, non-interactive elements with click handlers must have at least one keyboard listener jsx-a11y/click-events-have-key-events
57+
61:7 error Static HTML elements with event handlers require a role jsx-a11y/no-static-element-interactions
58+
61:7 error Anchor used as a button. Anchors are primarily expected to navigate. Use the button element instead. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
59+
62:9 error img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
60+
61+
/Users/dougr/git_code/webos-streams/src/index.tsx
62+
30:5 error Use array destructuring prefer-destructuring
63+
41:17 error JSX not allowed in files with extension '.tsx' react/jsx-filename-extension
64+
65+
✖ 86 problems (86 errors, 0 warnings)
66+
67+
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

0 commit comments

Comments
 (0)