Skip to content

Commit

Permalink
Tooling & Cleanup (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaradeniz authored Jun 6, 2019
1 parent 05a6787 commit 15b0868
Show file tree
Hide file tree
Showing 9 changed files with 800 additions and 44 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const path = require('path');

module.exports = {
extends: [require.resolve('@mkaradeniz/eslint-config-typescript-react')],
parserOptions: {
project: path.resolve(__dirname, './tsconfig.json'),
},
};
6 changes: 6 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
concurrent: false,
linters: {
'src/**/*.{ts,tsx}': ['eslint --fix', 'yarn test:types', 'git add'],
},
};
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "A React render prop to gradually build tracking data down the render tree.",
"keywords": [
"react",
"react-hook",
"tracking",
"typescript"
],
Expand Down Expand Up @@ -32,26 +33,38 @@
"docs:build": "docz build",
"docs:dev": "docz dev",
"format": "prettier \"./src/**/*.{ts,tsx}\" \"./docs/**/*.{mdx}\" --config ./prettier.config.js --write",
"lint": "eslint --ext .ts --ext .tsx \"./src/\" --fix",
"start": "tsdx watch",
"test": "tsdx test --env=jsdom",
"test:types": "tsc -p tsconfig.json --noEmit && :",
"test:watch": "tsdx test --env=jsdom --watch"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
"pre-commit": "pretty-quick --staged && lint-staged"
}
},
"dependencies": {
"deepmerge": "3.2.0",
"react-intersection-observer": "8.23.0"
},
"devDependencies": {
"@mkaradeniz/eslint-config-typescript-react": "2.0.0",
"@mkaradeniz/prettier-config": "2.0.0",
"@types/jest": "24.0.12",
"@types/react": "16.8.16",
"@types/react-dom": "16.8.4",
"@typescript-eslint/eslint-plugin": "1.6.0",
"@typescript-eslint/parser": "1.6.0",
"docz": "1.1.0",
"docz-theme-default": "1.1.0",
"eslint": "5.16.0",
"eslint-plugin-import": "2.17.2",
"eslint-plugin-jsx-a11y": "6.1.1",
"eslint-plugin-react": "7.11.0",
"eslint-plugin-react-hooks": "1.6.0",
"husky": "2.2.0",
"lint-staged": "8.2.0",
"prettier": "1.17.0",
"pretty-quick": "1.10.0",
"react": "16.8.6",
Expand Down
12 changes: 2 additions & 10 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
printWidth: 140,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
};
// eslint-disable-next-line import/no-extraneous-dependencies
module.exports = require('@mkaradeniz/prettier-config');
11 changes: 0 additions & 11 deletions src/Test.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/useTracktor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const useTracktor = ({
// Call the `dispatcher` with the provided `pageViewData`.
dispatcher(pageViewData);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// Computes the tracking data, and calls the `dispatcher` with it.
Expand Down
1 change: 1 addition & 0 deletions src/utils/computeTrackingData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const computeTrackingData = (...args: TrackingData[]) => {
try {
return deepmerge.all(args);
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);

throw Error(
Expand Down
2 changes: 2 additions & 0 deletions src/utils/defaultDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { Dispatcher, TrackingData } from '../types';

const defaultDispatcher = function dispatcher(trackingData: TrackingData) {
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.log(JSON.stringify(trackingData, null, 2));
}

// eslint-disable-next-line no-console
console.warn('No <TracktorProvider /> setup.');
} as Dispatcher;

Expand Down
Loading

0 comments on commit 15b0868

Please sign in to comment.