Skip to content

Commit 907e933

Browse files
Add Typecheck Prerequisites (godaddy#734)
1 parent deec24a commit 907e933

File tree

79 files changed

+959
-341
lines changed

Some content is hidden

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

79 files changed

+959
-341
lines changed

package-lock.json

+213-201
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
"nx": "^15.0.13",
5858
"react": "^18.2.0",
5959
"react-dom": "^18.2.0",
60-
"rimraf": "^3.0.2"
60+
"rimraf": "^3.0.2",
61+
"typescript": "^5.4.5"
6162
},
6263
"eslintConfig": {
6364
"extends": [

packages/create-gasket-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"devDependencies": {
3737
"cross-env": "^7.0.3",
3838
"eslint": "^8.56.0",
39-
"eslint-config-godaddy": "^7.0.2",
39+
"eslint-config-godaddy": "^7.1.0",
4040
"eslint-plugin-jest": "^27.6.3",
4141
"eslint-plugin-json": "^3.1.0",
4242
"eslint-plugin-unicorn": "^44.0.0",

packages/gasket-assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@svgr/core": "^6.2.0",
4646
"babel-plugin-add-module-exports": "^1.0.4",
4747
"eslint": "^8.56.0",
48-
"eslint-config-godaddy": "^7.0.2",
48+
"eslint-config-godaddy": "^7.1.0",
4949
"eslint-plugin-json": "^3.1.0",
5050
"eslint-plugin-unicorn": "^44.0.0",
5151
"mkdirp": "^1.0.4",

packages/gasket-cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"cross-env": "^7.0.3",
8787
"diagnostics": "^2.0.2",
8888
"eslint": "^8.56.0",
89-
"eslint-config-godaddy": "^7.0.2",
89+
"eslint-config-godaddy": "^7.1.0",
9090
"eslint-plugin-jest": "^27.6.3",
9191
"eslint-plugin-json": "^3.1.0",
9292
"eslint-plugin-unicorn": "^44.0.0",

packages/gasket-data/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"eslint-plugin-json": "^3.1.0",
4747
"eslint-plugin-unicorn": "^44.0.0",
4848
"jest": "^29.7.0",
49-
"typescript": "^5.4.2"
49+
"typescript": "^5.4.5"
5050
},
5151
"eslintConfig": {
5252
"extends": [

packages/gasket-engine/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"devDependencies": {
4646
"cross-env": "^7.0.3",
4747
"eslint": "^8.56.0",
48-
"eslint-config-godaddy": "^7.0.2",
48+
"eslint-config-godaddy": "^7.1.0",
4949
"eslint-plugin-jest": "^27.6.3",
5050
"eslint-plugin-json": "^3.1.0",
5151
"eslint-plugin-unicorn": "^44.0.0",

packages/gasket-fetch/lib/browser.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
// Wrapper to access window.fetch in case of polyfill or monkey patch
2-
function fetchWrapper(...args) {
3-
return window.fetch(...args);
1+
/**
2+
* Wrapper to access window.fetch in case of polyfill or monkey patch
3+
* @type {import('./index').fetch}
4+
*/
5+
function fetchWrapper(input, init) {
6+
return window.fetch(input, init);
47
}
58

9+
// @ts-ignore - TS doesn't like adding properties to a function
610
exports = fetchWrapper; // To import fetch from @gasket/fetch
711
exports.default = fetchWrapper; // For TypeScript consumers without esModuleInterop.
812
exports.Headers = window.Headers;

packages/gasket-fetch/lib/index.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
export function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1+
export function fetch(
2+
input: RequestInfo,
3+
init?: RequestInit
4+
): Promise<Response>;
5+
26
export default fetch;

packages/gasket-fetch/lib/node.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
const fetch = require('node-fetch');
2+
23
fetch.AbortController = require('abort-controller');
4+
35
module.exports = fetch;

packages/gasket-fetch/package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"test:runner": "npm run test:server && npm run test:browser",
1616
"test:browser": "jest --detectOpenHandles --env=jsdom test/browser.spec.js",
1717
"test:server": "jest --env=node test/server.spec.js",
18-
"posttest": "npm run lint"
18+
"posttest": "npm run lint && npm run typecheck",
19+
"typecheck": "tsc",
20+
"typecheck:watch": "tsc --watch"
1921
},
2022
"repository": {
2123
"type": "git",
@@ -49,22 +51,25 @@
4951
"core-js": "^3.35.0",
5052
"cross-env": "^7.0.3",
5153
"eslint": "^8.56.0",
52-
"eslint-config-godaddy": "^7.0.2",
54+
"eslint-config-godaddy": "^7.1.0",
5355
"eslint-plugin-jest": "^27.6.3",
5456
"eslint-plugin-json": "^3.1.0",
5557
"eslint-plugin-unicorn": "^44.0.0",
5658
"jest": "^29.7.0",
5759
"jsdom": "^20.0.0",
5860
"regenerator-runtime": "^0.14.1",
61+
"typescript": "^5.4.5",
5962
"whatwg-fetch": "3.6.20"
6063
},
6164
"eslintConfig": {
6265
"extends": [
6366
"godaddy",
64-
"plugin:jest/recommended"
67+
"plugin:jest/recommended",
68+
"plugin:jsdoc/recommended-typescript-flavor"
6569
],
6670
"plugins": [
67-
"unicorn"
71+
"unicorn",
72+
"jsdoc"
6873
],
6974
"rules": {
7075
"unicorn/filename-case": "error"

packages/gasket-fetch/tsconfig.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"checkJs": true,
5+
"noEmit": true,
6+
"skipLibCheck": true,
7+
"resolveJsonModule": true,
8+
"esModuleInterop": true,
9+
"lib": [
10+
"esnext",
11+
"dom"
12+
],
13+
"types": [
14+
"@types/jest"
15+
]
16+
},
17+
"exclude": [
18+
"test",
19+
"coverage"
20+
]
21+
}

packages/gasket-helper-intl/package.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"test:coverage": "jest --coverage",
1818
"posttest": "npm run lint",
1919
"prepack": "npm run docs",
20-
"docs": "jsdoc2md --plugin @godaddy/dmd --files lib/index.js > docs/api.md"
20+
"docs": "jsdoc2md --plugin @godaddy/dmd --files lib/index.js > docs/api.md",
21+
"typecheck:skip": "tsc",
22+
"typecheck:watch": "tsc --watch"
2123
},
2224
"repository": {
2325
"type": "git",
@@ -47,20 +49,23 @@
4749
"@godaddy/dmd": "^1.0.4",
4850
"cross-env": "^7.0.3",
4951
"eslint": "^8.56.0",
50-
"eslint-config-godaddy": "^7.0.2",
52+
"eslint-config-godaddy": "^7.1.0",
5153
"eslint-plugin-jest": "^27.6.3",
5254
"eslint-plugin-json": "^3.1.0",
5355
"eslint-plugin-unicorn": "^44.0.0",
5456
"jest": "^29.7.0",
55-
"jsdoc-to-markdown": "^7.1.0"
57+
"jsdoc-to-markdown": "^7.1.0",
58+
"typescript": "^5.4.5"
5659
},
5760
"eslintConfig": {
5861
"extends": [
5962
"godaddy",
60-
"plugin:jest/recommended"
63+
"plugin:jest/recommended",
64+
"plugin:jsdoc/recommended-typescript-flavor"
6165
],
6266
"plugins": [
63-
"unicorn"
67+
"unicorn",
68+
"jsdoc"
6469
],
6570
"rules": {
6671
"unicorn/filename-case": "error"
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"checkJs": true,
5+
"noEmit": true,
6+
"skipLibCheck": true,
7+
"resolveJsonModule": true,
8+
"esModuleInterop": true,
9+
"lib": [
10+
"esnext",
11+
"dom"
12+
],
13+
"types": [
14+
"@types/jest"
15+
]
16+
},
17+
"exclude": [
18+
"test",
19+
"coverage"
20+
]
21+
}

packages/gasket-log/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"babel-eslint": "^10.1.0",
6060
"cross-env": "^7.0.3",
6161
"eslint": "^8.56.0",
62-
"eslint-config-godaddy": "^7.0.2",
62+
"eslint-config-godaddy": "^7.1.0",
6363
"eslint-plugin-babel": "^5.3.1",
6464
"eslint-plugin-jest": "^27.6.3",
6565
"eslint-plugin-json": "^3.1.0",

packages/gasket-nextjs/package.json

+9-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"test:coverage": "jest --coverage",
1919
"posttest": "npm run lint",
2020
"build": "babel src -d lib --delete-dir-on-start",
21-
"prepublishOnly": "npm run build"
21+
"prepublishOnly": "npm run build",
22+
"typecheck:skip": "tsc",
23+
"typecheck:watch": "tsc --watch"
2224
},
2325
"repository": {
2426
"type": "git",
@@ -63,7 +65,8 @@
6365
"next": "13.1.1",
6466
"prop-types": "^15.8.1",
6567
"react": "^18.2.0",
66-
"react-dom": "^18.2.0"
68+
"react-dom": "^18.2.0",
69+
"typescript": "^5.4.5"
6770
},
6871
"peerDependencies": {
6972
"next": ">=10.2.0 <= 13.1.1",
@@ -73,10 +76,12 @@
7376
"eslintConfig": {
7477
"extends": [
7578
"godaddy-react",
76-
"plugin:jest/recommended"
79+
"plugin:jest/recommended",
80+
"plugin:jsdoc/recommended-typescript-flavor"
7781
],
7882
"plugins": [
79-
"unicorn"
83+
"unicorn",
84+
"jsdoc"
8085
],
8186
"rules": {
8287
"unicorn/filename-case": "error"

packages/gasket-nextjs/src/gasket-data-provider.js

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const GasketDataContext = React.createContext({});
55

66
/**
77
* Provider for the GasketData, adds context to child elements.
8-
*
98
* @param {object} props - Props
109
* @param {GasketData} props.gasketData - Object of GasketData
1110
* @param {JSX.Element} props.children - Element to add GasketData context too
@@ -23,4 +22,3 @@ GasketDataProvider.propTypes = {
2322
gasketData: PropTypes.object,
2423
children: PropTypes.node
2524
};
26-

packages/gasket-nextjs/src/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ export const GasketDataProvider: ComponentType<PropsWithChildren<{ gasketData: G
4545
*
4646
* @returns {function} wrapper
4747
*/
48-
export function withGasketDataProvider(): SubstitutableHOC;
48+
export function withGasketDataProvider(): SubstitutableHOC;

packages/gasket-nextjs/src/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import htmlescape from 'htmlescape';
55

66
/**
77
* Renders a script tag with JSON gasketData
8-
*
98
* @param {object} props - Props
109
* @param {GasketData} props.data - Gasket data from response
1110
* @returns {JSX.Element} script
@@ -28,7 +27,6 @@ GasketDataScript.propTypes = {
2827
/**
2928
* Make a wrapper to extend the Next.js Document, injecting a script with the
3029
* `gasketData` from the response object.
31-
*
3230
* @param {object} [options] - Configuration for wrapper
3331
* @param {number} [options.index] - Force script injection at particular index
3432
* @returns {function(Document)} wrapper
@@ -40,7 +38,6 @@ export function withGasketData(options = {}) {
4038
* To avoid polluting <head/>, we want to render our JSON in the <body/>
4139
* but before our other scripts so that it is available to query.
4240
* In a basic Next.js app, this is between the Main and NextScript tags.*
43-
*
4441
* @param {Array} bodyChildren - Children of body element
4542
* @returns {number} index
4643
* @private
@@ -59,7 +56,6 @@ export function withGasketData(options = {}) {
5956

6057
/**
6158
* Extend the Document
62-
*
6359
* @param {Document} Document - Next Document class to wrap
6460
* @returns {Document} extended Document
6561
*/

packages/gasket-nextjs/src/use-gasket-data.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { GasketDataContext } from './gasket-data-provider';
33

44
/**
55
* React that fetches GasketData in elements context and returns it
6-
*
76
* @returns {object} GasketData
87
*/
98
export const useGasketData = () => {

packages/gasket-nextjs/src/with-gasket-data-provider.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ const clientGasketData = typeof window === 'object' ? require('@gasket/data') :
77
/**
88
* Make an HOC that adds a provider for the GasketData.
99
* This can be used to wrap a top level React, Next.js custom App component or Next.js custom Document component.
10-
*
11-
* @returns {function} wrapper
10+
* @returns {Function} wrapper
1211
*/
1312
export const withGasketDataProvider = () => (WrappedComponent) => {
1413

packages/gasket-nextjs/test/gasket-data-script.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';;
1+
import React from 'react';
22
import { render, queryByAttribute } from '@testing-library/react';
33

44
import { GasketDataScript } from '../src';

packages/gasket-nextjs/test/with-gasket-data-provider.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';;
1+
import React from 'react';
22
import { render } from '@testing-library/react';
33

44
describe('withGasketDataProvider', function () {

packages/gasket-nextjs/test/with-gasket-data.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class MyDocument extends Document {
2727
/**
2828
* Recursively searches through the rendered element tree for the first element
2929
* that matches the search type
30-
*
3130
* @param {object} renderedElement - The element that was rendered by the
3231
* component.
3332
* @param {string} searchType - The type of the element you're looking for.

packages/gasket-nextjs/tsconfig.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"jsx": "react",
4+
"allowJs": true,
5+
"checkJs": true,
6+
"noEmit": true,
7+
"skipLibCheck": true,
8+
"resolveJsonModule": true,
9+
"esModuleInterop": true,
10+
"lib": [
11+
"esnext",
12+
"dom"
13+
],
14+
"types": [
15+
"@types/jest"
16+
]
17+
},
18+
"include": [
19+
"src"
20+
],
21+
"exclude": [
22+
"test",
23+
"coverage",
24+
"lib"
25+
]
26+
}

packages/gasket-plugin-analyze/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"eslint-plugin-json": "^3.1.0",
5353
"eslint-plugin-unicorn": "^44.0.0",
5454
"jest": "^29.7.0",
55-
"typescript": "^5.4.2"
55+
"typescript": "^5.4.5"
5656
},
5757
"eslintConfig": {
5858
"extends": [

packages/gasket-plugin-command/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@oclif/errors": "^1.3.5",
5252
"cross-env": "^7.0.3",
5353
"eslint": "^8.56.0",
54-
"eslint-config-godaddy": "^7.0.2",
54+
"eslint-config-godaddy": "^7.1.0",
5555
"eslint-plugin-jest": "^27.6.3",
5656
"eslint-plugin-json": "^3.1.0",
5757
"eslint-plugin-unicorn": "^44.0.0",

packages/gasket-plugin-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@gasket/engine": "^6.46.2",
4646
"cross-env": "^7.0.3",
4747
"eslint": "^8.56.0",
48-
"eslint-config-godaddy": "^7.0.2",
48+
"eslint-config-godaddy": "^7.1.0",
4949
"eslint-plugin-jest": "^27.6.3",
5050
"eslint-plugin-json": "^3.1.0",
5151
"eslint-plugin-unicorn": "^44.0.0",

0 commit comments

Comments
 (0)