Skip to content

Commit 1fb84dd

Browse files
authored
Merge pull request #28 from PiwikPRO/fix/eslint-and-proper-types
fix: enable eslint and follow it's errors
2 parents c8b47cc + 21d04ef commit 1fb84dd

32 files changed

Lines changed: 162 additions & 306 deletions

.eslintrc

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

.eslintrc.cjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
const config = {
3+
parser: '@typescript-eslint/parser',
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended-type-checked',
7+
],
8+
plugins: ['@typescript-eslint'],
9+
ignorePatterns:[".eslintrc.cjs", "example"],
10+
parserOptions: {
11+
project:true,
12+
tsconfigRootDir: __dirname,
13+
},
14+
}
15+
16+
module.exports = config

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.19.0

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"semi": false,
55
"tabWidth": 2,
66
"bracketSpacing": true,
7-
"jsxBracketSameLine": false,
7+
"bracketSameLine": false,
88
"arrowParens": "always",
99
"trailingComma": "none"
1010
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Custom events enable tracking visitor actions that are not predefined in the exi
190190
import { CustomEvent } from '@piwikpro/react-piwik-pro'
191191
```
192192
#### Methods
193-
* `trackEvent(category: string, action: string, name?: string, value?: number) ` - Tracks a custom event, e.g. when a visitor interacts with the page.
193+
* `trackEvent(category: string, action: string, name?: string, value?: number, dimensions?: Object) ` - Tracks a custom event, e.g. when a visitor interacts with the page.
194194

195195
### Site search Service
196196
Site search tracking gives you insights into how visitors interact with the search engine on your website - what they search for and how many results they get back.

example/package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/main.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ const App = () => (
3636
)
3737

3838
const container = document.getElementById('root')
39-
// @ts-ignore
39+
if(!container){
40+
throw new Error("#root element not found")
41+
}
42+
4043
createRoot(container).render(<App />)

example/src/pages/CustomEventPage.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ const CustomEventPage: FunctionComponent = () => {
4545
variant='contained'
4646
onClick={() => {
4747
setFinish(true)
48-
CustomEvent.trackEvent('user_data_form', 'submit')
48+
CustomEvent.trackEvent(
49+
'user_data_form',
50+
'submit',
51+
'success',
52+
10,
53+
{ dimension1: 'value1' }
54+
)
4955
enqueueSnackbar(
50-
"CustomEvent.trackEvent('user_data_form', 'submit')",
56+
"CustomEvent.trackEvent('user_data_form', 'submit', 'success', 10, { dimension1: 'value1' })",
5157
{ variant: 'success' }
5258
)
5359
}}

package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
2222
"test:watch": "react-scripts test --env=jsdom",
2323
"predeploy": "cd example && yarn install && yarn run build",
24-
"deploy": "gh-pages -d example/build"
24+
"deploy": "gh-pages -d example/build",
25+
"format":"prettier src/**/*.ts --list-different",
26+
"format:fix":"npm run format -- --write",
27+
"typecheck": "tsc --noEmit"
2528
},
2629
"peerDependencies": {
2730
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -41,15 +44,6 @@
4144
"babel-eslint": "^10.1.0",
4245
"cross-env": "^7.0.3",
4346
"eslint": "^8.56.0",
44-
"eslint-config-prettier": "^9.1.0",
45-
"eslint-config-standard": "^17.1.0",
46-
"eslint-config-standard-react": "^13.0.0",
47-
"eslint-plugin-import": "^2.29.1",
48-
"eslint-plugin-node": "^11.1.0",
49-
"eslint-plugin-prettier": "^5.1.2",
50-
"eslint-plugin-promise": "^6.1.1",
51-
"eslint-plugin-react": "^7.33.2",
52-
"eslint-plugin-standard": "^5.0.0",
5347
"gh-pages": "^6.1.1",
5448
"microbundle-crl": "^0.13.11",
5549
"npm-run-all": "^4.1.5",

src/core/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { PiwikProWindow } from '../interfaces/piwikpro.window'
2-
31
function init(containerId: string, containerUrl: string, nonce?: string) {
42
if (!containerId) {
53
console.error('Empty tracking code for Piwik Pro.')
@@ -37,7 +35,7 @@ tags.async=!0,tags.src="${containerUrl}/"+id+".js"+qPString,scripts.parentNode.i
3735

3836
export const IS_DEBUG =
3937
(typeof process !== 'undefined' && process.env.NODE_ENV === 'development') ||
40-
(typeof window !== 'undefined' && (window as PiwikProWindow).IS_DEBUG) ||
38+
(typeof window !== 'undefined' && window.IS_DEBUG) ||
4139
false
4240

4341
export default {

0 commit comments

Comments
 (0)