Skip to content

Commit e1b0b9d

Browse files
author
F1LT3R
committed
Get linting and testing to work for TS and JS in the same repo here (including coverage).
1 parent 6dc1bc5 commit e1b0b9d

23 files changed

+359
-159
lines changed

‎package.json

+9-11
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
]
2020
},
2121
"devDependencies": {
22-
"jest-prop-type-error": "^1.1.0",
23-
"lerna": "^3.10.7",
24-
"prettier": "^1.16.1"
25-
},
26-
"dependencies": {
2722
"babel-eslint": "10.0.3",
2823
"eslint": "6.6.0",
2924
"eslint-config-prettier": "^4.2.0",
@@ -33,15 +28,18 @@
3328
"eslint-plugin-jsx-a11y": "^6.2.1",
3429
"eslint-plugin-prettier": "^3.0.1",
3530
"eslint-plugin-react": "^7.12.4",
36-
"eslint-plugin-react-hooks": "^1.6.0"
31+
"eslint-plugin-react-hooks": "^1.6.0",
32+
"jest-prop-type-error": "^1.1.0",
33+
"lerna": "^3.10.7",
34+
"prettier": "^1.16.1"
3735
},
3836
"jest": {
3937
"collectCoverageFrom": [
40-
"src/**/*.{js,jsx}",
41-
"!src/setupTests.{js,jsx}",
42-
"!src/index.{js,jsx}",
43-
"!src/serviceWorker.{js,jsx}",
44-
"!src/**/*.(spec|test|stories).{js,jsx}"
38+
"src/**/*.{js,jsx,ts,tsx}",
39+
"!src/setupTests.{js,jsx,ts,tsx}",
40+
"!src/index.{js,jsx,ts,tsx}",
41+
"!src/serviceWorker.{js,jsx,ts,tsx}",
42+
"!src/**/*.(spec|test|stories).{js,jsx,ts,tsx}"
4543
]
4644
}
4745
}
File renamed without changes.
File renamed without changes.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": ["react", "prettier", "jsx-a11y", "import"],
4+
"extends": ["react-app", "prettier", "prettier/react"],
5+
"globals": {
6+
"expect": true,
7+
"describe": true,
8+
"it": true,
9+
"fixture": true,
10+
"test": true,
11+
"jest": true,
12+
"document": true,
13+
"window": true,
14+
"fetch": true,
15+
"navigator": true
16+
},
17+
"rules": {
18+
"space-before-function-paren": 0,
19+
"quotes": 0,
20+
"operator-linebreak": 0,
21+
"react/jsx-tag-spacing": [
22+
"error",
23+
{
24+
"beforeSelfClosing": "always"
25+
}
26+
]
27+
}
28+
}

‎packages/apps/app-multi-comps/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,9 @@
5151
"lines": 98
5252
}
5353
}
54+
},
55+
"devDependencies": {
56+
"eslint-config-prettier": "^6.8.0",
57+
"eslint-plugin-prettier": "^3.1.2"
5458
}
5559
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
singleQuote: true,
3+
printWidth: 80,
4+
jsxSingleQuote: false,
5+
bracketSpacing: false,
6+
arrowParens: 'avoid'
7+
};
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": ["react", "prettier", "jsx-a11y", "import"],
4+
"extends": ["react-app", "prettier", "prettier/react"],
5+
"globals": {
6+
"expect": true,
7+
"describe": true,
8+
"it": true,
9+
"fixture": true,
10+
"test": true,
11+
"jest": true,
12+
"document": true,
13+
"window": true,
14+
"fetch": true,
15+
"navigator": true
16+
},
17+
"rules": {
18+
"space-before-function-paren": 0,
19+
"quotes": 0,
20+
"operator-linebreak": 0,
21+
"react/jsx-tag-spacing": [
22+
"error",
23+
{
24+
"beforeSelfClosing": "always"
25+
}
26+
]
27+
}
28+
}

‎packages/apps/app-single-comp/package.json

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"cross-env": "5.0.5",
1010
"enzyme": "^3.9.0",
1111
"enzyme-adapter-react-16": "^1.12.1",
12+
"eslint-config-prettier": "^6.8.0",
13+
"eslint-config-react-app": "^5.1.0",
14+
"eslint-plugin-prettier": "^3.1.2",
1215
"gh-pages": "^2.0.1",
1316
"react": "^16.8.6",
1417
"react-dom": "^16.8.6",
@@ -51,5 +54,9 @@
5154
"lines": 98
5255
}
5356
}
57+
},
58+
"devDependencies": {
59+
"eslint-config-prettier": "^6.8.0",
60+
"eslint-plugin-prettier": "^3.1.2"
5461
}
5562
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
singleQuote: true,
3+
printWidth: 80,
4+
jsxSingleQuote: false,
5+
bracketSpacing: false,
6+
arrowParens: 'avoid'
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/node_modules/**
2+
**/dist/**
3+
**/storybook-static/**
4+
**/coverage/**
5+
**/build/**
6+
**/.git/**
7+
**/public/**
8+
serviceWorker.ts
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
extends: [
4+
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
5+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
6+
],
7+
parserOptions: {
8+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
9+
sourceType: 'module', // Allows for the use of imports
10+
ecmaFeatures: {
11+
jsx: true, // Allows for the parsing of JSX
12+
},
13+
},
14+
rules: {
15+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
16+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
17+
},
18+
settings: {
19+
react: {
20+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
21+
},
22+
},
23+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 4,
7+
};
+56-38
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
11
{
2-
"name": "app-typescript",
3-
"version": "0.1.0",
4-
"private": true,
5-
"dependencies": {
6-
"@project/components-typescript": "1.0.0",
7-
"@react-workspaces/react-scripts": "^3.3.0-alpha-08",
8-
"@testing-library/jest-dom": "^4.2.4",
9-
"@testing-library/react": "^9.3.2",
10-
"@testing-library/user-event": "^7.1.2",
11-
"@types/jest": "^24.0.0",
12-
"@types/node": "^12.0.0",
13-
"@types/react": "^16.9.0",
14-
"@types/react-dom": "^16.9.0",
15-
"react": "^16.12.0",
16-
"react-dom": "^16.12.0",
17-
"typescript": "~3.7.2"
18-
},
19-
"scripts": {
20-
"start": "react-scripts start",
21-
"build": "react-scripts build",
22-
"test": "react-scripts test",
23-
"eject": "react-scripts eject"
24-
},
25-
"eslintConfig": {
26-
"extends": "react-app"
27-
},
28-
"browserslist": {
29-
"production": [
30-
">0.2%",
31-
"not dead",
32-
"not op_mini all"
33-
],
34-
"development": [
35-
"last 1 chrome version",
36-
"last 1 firefox version",
37-
"last 1 safari version"
38-
]
39-
}
2+
"name": "app-typescript",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@project/components-typescript": "1.0.0",
7+
"@react-workspaces/react-scripts": "^3.3.0-alpha-08",
8+
"@testing-library/jest-dom": "^4.2.4",
9+
"@testing-library/react": "^9.3.2",
10+
"@testing-library/user-event": "^7.1.2",
11+
"@types/jest": "^24.0.0",
12+
"@types/node": "^12.0.0",
13+
"@types/react": "^16.9.0",
14+
"@types/react-dom": "^16.9.0",
15+
"react": "^16.12.0",
16+
"react-dom": "^16.12.0",
17+
"typescript": "~3.7.2"
18+
},
19+
"scripts": {
20+
"start": "react-scripts start",
21+
"build": "react-scripts build",
22+
"test": "react-scripts test",
23+
"eject": "react-scripts eject",
24+
"lint": "eslint ./src/**/*.{ts,tsx} --max-warnings=0 --format=codeframe"
25+
},
26+
"eslintConfig": {
27+
"extends": "react-app"
28+
},
29+
"browserslist": {
30+
"production": [
31+
">0.2%",
32+
"not dead",
33+
"not op_mini all"
34+
],
35+
"development": [
36+
"last 1 chrome version",
37+
"last 1 firefox version",
38+
"last 1 safari version"
39+
]
40+
},
41+
"jest": {
42+
"collectCoverageFrom": [
43+
"src/**/*.{ts,tsx}",
44+
"!src/setupTests.{ts,tsx}",
45+
"!src/index.{ts,tsx}",
46+
"!src/serviceWorker.{ts,tsx}",
47+
"!src/**/*.(spec|test|stories).{ts,tsx}"
48+
],
49+
"coverageThreshold": {
50+
"global": {
51+
"statements": 98,
52+
"branches": 98,
53+
"functions": 98,
54+
"lines": 98
55+
}
56+
}
57+
}
4058
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/node_modules/**
2+
**/dist/**
3+
**/storybook-static/**
4+
**/coverage/**
5+
**/build/**
6+
**/.git/**
7+
**/public/**
8+
serviceWorker.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
extends: [
4+
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
5+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
6+
],
7+
parserOptions: {
8+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
9+
sourceType: 'module', // Allows for the use of imports
10+
ecmaFeatures: {
11+
jsx: true, // Allows for the parsing of JSX
12+
},
13+
},
14+
rules: {
15+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
16+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
17+
},
18+
settings: {
19+
react: {
20+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
21+
},
22+
},
23+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
printWidth: 120,
6+
tabWidth: 4,
7+
};

0 commit comments

Comments
 (0)