Skip to content

Commit

Permalink
Merge pull request #164 from Vikki123/typescript_migrate
Browse files Browse the repository at this point in the history
feat: typescript support for the project
  • Loading branch information
reubenae authored Oct 29, 2021
2 parents 7d32864 + 0e3a358 commit 0dd9973
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 353 deletions.
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@ module.exports = {
"eslint:recommended",
"plugin:jest/recommended"
],
parser: "babel-eslint"
parser: "babel-eslint",
overrides: [{
files: ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
}]
};
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parser": "typescript",
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
}
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"test": "jest",
"build": "webpack",
"test:coverage": "npm test -- --coverage && cat ./coverage/lcov.info | coveralls",
"lint:fix": "eslint '{src,tests}/**/*.js' --fix",
"lint": "eslint '{src,tests}/**/*.js'",
"lint:fix": "eslint '{src,tests}/**/*.{js,ts} --fix",
"lint": "eslint '{src,tests}/**/*.{js,ts}'",
"format": "lint-staged",
"prettier": "prettier '{src,tests}/**/*.js' --write --single-quote --tab-width 4 --no-bracket-spacing --print-width 120",
"prettier": "prettier '{src,tests}/**/*.{js,ts}' --config .prettierrc --write",
"prettier:fix": "prettier '{src,tests}/**/*.{js,ts}' --config .prettierrc",
"clean": "rm -rf node_modules",
"rebuild": "npm run clean && npm install && npm run build",
"prepublishOnly": "webpack"
Expand All @@ -25,6 +26,11 @@
"eslint --fix",
"prettier --write",
"git add"
],
"**/*.ts": [
"eslint --fix",
"prettier --write",
"git add"
]
},
"repository": {
Expand Down Expand Up @@ -56,6 +62,9 @@
"@semantic-release/commit-analyzer": "^9.0.1",
"@semantic-release/npm": "^8.0.0",
"@semantic-release/release-notes-generator": "^10.0.2",
"@types/jest": "^26.0.1",
"@typescript-eslint/eslint-plugin": "5.2.0",
"@typescript-eslint/parser": "5.2.0",
"all-contributors-cli": "^6.17.4",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.1.0",
Expand All @@ -71,6 +80,9 @@
"prettier": "^2.0.5",
"react-addons-test-utils": "^15.6.2",
"semantic-release": "^18.0.0",
"ts-jest": "^26.0.1",
"ts-loader": "^8.3.0",
"typescript": "^4.4.4",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"
},
Expand All @@ -81,7 +93,7 @@
"lcov"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"src/**/*.{js,jsx,tx,tsx}",
"!**/test/**"
]
},
Expand Down
28 changes: 0 additions & 28 deletions src/js/index.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/js/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export {
fraudPreventionHeadersEnum,
getFraudPreventionHeaders,
getScreenDetails,
windowDetails,
getGovClientBrowserJSUserAgentHeader,
getGovClientBrowserPluginsHeader,
getGovClientBrowserDoNotTrackHeader,
getGovClientDeviceID,
getGovClientTimezoneHeader,
getGovClientLocalIPsHeader,
getGovClientWindowSizeHeader
} from './hmrc/mtdFraudPrevention';
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"outDir": "dist",
"allowJs": true, // Remove once migration is done
"sourceMap": true,
"declaration": true,
"declarationMap": true,
},
"include": [
"src/**/*",
],
}
11 changes: 10 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
const path = require('path');

module.exports = {
entry: './src/js/index.js',
entry: './src/js/index.ts',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: "umd"
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader", exclude: /node_modules/, }
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
},
};
Loading

0 comments on commit 0dd9973

Please sign in to comment.