Skip to content

Commit

Permalink
Merge pull request #4 from guardian/gh-switch-to-eslint
Browse files Browse the repository at this point in the history
Use eslint for linting typescript
  • Loading branch information
GHaberis authored Aug 1, 2019
2 parents fdc3104 + a0b2458 commit 5d84b82
Show file tree
Hide file tree
Showing 7 changed files with 764 additions and 249 deletions.
1 change: 1 addition & 0 deletions . eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/**/*.js
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "jest"],
"extends": [
"plugin:@typescript-eslint/recommended",
"airbnb-typescript/base",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"env": {
"jest/globals": true,
"browser": true
},
"rules": {
"prettier/prettier": 2,
"import/no-default-export": 2,
"interface-over-type-literal": 0,
"import-name": 0,
"object-literal-sort-keys": 0,
"interface-name": 0
},
"overrides": [
{
"files": "src/**/*.test.ts",
"rules": {
"@typescript-eslint/explicit-function-return-type": 0
}
}
]
}
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[typescript]": {
"editor.formatOnSave": false
},
"eslint.autoFixOnSave": true,
"eslint.validate": [{ "language": "typescript", "autoFix": true }]
}
84 changes: 44 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
{
"name": "consent-management-platform",
"version": "1.0.0-alpha.1",
"description": "Library of useful utilities for managing consent state across *.theguardian.com",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "jest --config jestconfig.json",
"build": "tsc",
"format": "yarn lint --fix",
"lint": "tslint -p tsconfig.json",
"prepare": "yarn build",
"prepublishOnly": "yarn test && yarn lint",
"preversion": "yarn lint",
"version": "yarn format && git add -A src",
"postversion": "git push && git push --tags"
},
"husky": {
"hooks": {
"pre-push": "yarn lint && yarn test"
}
},
"repository": "https://github.com/guardian/consent-management-platform.git",
"homepage": "https://github.com/guardian/consent-management-platform.git",
"author": "George Haberis <[email protected]>",
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "^24.0.16",
"husky": "^3.0.2",
"jest": "^24.8.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"tslint": "^5.18.0",
"tslint-config-airbnb": "^5.11.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.5.3"
},
"files": [
"lib/**/*"
]
"name": "consent-management-platform",
"version": "1.0.0-alpha.1",
"description": "Library of useful utilities for managing consent state across *.theguardian.com",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "jest --config jestconfig.json",
"build": "tsc",
"format": "yarn validate --fix",
"validate": "tsc --noEmit && eslint src/**/*.ts",
"prepare": "yarn build",
"prepublishOnly": "yarn test && yarn validate",
"preversion": "yarn validate",
"version": "yarn format && git add -A src",
"postversion": "git push && git push --tags"
},
"husky": {
"hooks": {
"pre-push": "yarn validate && yarn test"
}
},
"repository": "https://github.com/guardian/consent-management-platform.git",
"homepage": "https://github.com/guardian/consent-management-platform.git",
"author": "George Haberis <[email protected]>",
"license": "Apache-2.0",
"devDependencies": {
"@types/jest": "^24.0.16",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"eslint": "^6.1.0",
"eslint-config-airbnb-typescript": "^4.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.14.1",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^3.0.2",
"jest": "^24.8.0",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"typescript": "^3.5.3"
},
"files": [
"lib/**/*"
]
}
2 changes: 1 addition & 1 deletion src/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getCookieValues = (name: string): string[] => {
const nameEq = `${name}=`;
const cookies = document.cookie.split(';');

return cookies.reduce((acc: string[], cookie: string) => {
return cookies.reduce((acc: string[], cookie: string): string[] => {
const cookieTrimmed = cookie.trim();

if (cookieTrimmed.indexOf(nameEq) === 0) {
Expand Down
25 changes: 0 additions & 25 deletions tslint.json

This file was deleted.

Loading

0 comments on commit 5d84b82

Please sign in to comment.