Skip to content

Commit

Permalink
chore: enable linting of TS code (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Jul 13, 2022
1 parent 0dcc864 commit 49ceff9
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 52 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
20 changes: 14 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
"es6": true,
"jest": true
},
"globals": {
"Promise": true,
"describe": true,
"it": true,
"expect": true
},
"plugins": ["eslint-plugin-import", "import", "jest"],
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": ["./", "node_modules"]
}
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
}
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
Expand Down Expand Up @@ -47,6 +44,17 @@
"rules": {
"import/no-default-export": "error"
}
},
{
"files": "**/*.ts",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/array-type": "error",
// should probably enable this, but it's a bit too strict for now
"@typescript-eslint/no-explicit-any": "off"
}
}
]
}
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ jobs:
node-version: lts/*
cache: yarn
- run: yarn install
- run: yarn build
- run: yarn lint
- run: yarn typecheck
1 change: 1 addition & 0 deletions examples/typescript/all/test/add.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { add } from '../src/add';

describe('add', () => {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"build": "babel src -d dist --ignore \"**/*.test.js\"",
"lint": "eslint src",
"lint": "eslint .",
"lint:fix": "yarn lint --fix",
"prepare": "husky install",
"prepublishOnly": "yarn build",
Expand Down Expand Up @@ -39,10 +39,13 @@
"@babel/preset-env": "^7.14.7",
"@jest/expect-utils": "^28.0.0",
"@types/jest": "^28.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.6",
"@typescript-eslint/parser": "^5.30.6",
"babel-jest": "^28.0.0",
"babel-jest-assertions": "^0.1.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^3.2.5",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^26.0.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
28 changes: 14 additions & 14 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,21 @@ declare namespace jest {
*
* @param {Array.<String>} keys
*/
toContainKeys<E = any>(keys: ReadonlyArray<keyof E | string>): R;
toContainKeys<E = any>(keys: readonly (keyof E | string)[]): R;

/**
* Use `.toContainAllKeys` when checking if an object only contains all of the provided keys.
*
* @param {Array.<String>} keys
*/
toContainAllKeys<E = any>(keys: ReadonlyArray<keyof E | string>): R;
toContainAllKeys<E = any>(keys: readonly (keyof E | string)[]): R;

/**
* Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys.
*
* @param {Array.<String>} keys
*/
toContainAnyKeys<E = any>(keys: ReadonlyArray<keyof E | string>): R;
toContainAnyKeys<E = any>(keys: readonly (keyof E | string)[]): R;

/**
* Use `.toContainValue` when checking if an object contains the provided value.
Expand Down Expand Up @@ -292,21 +292,21 @@ declare namespace jest {
*
* @param {Array.<Array.<keyof E, E[keyof E]>>} entries
*/
toContainEntries<E = any>(entries: ReadonlyArray<readonly [keyof E, E[keyof E]]>): R;
toContainEntries<E = any>(entries: readonly (readonly [keyof E, E[keyof E]])[]): R;

/**
* Use `.toContainAllEntries` when checking if an object only contains all of the provided entries.
*
* @param {Array.<Array.<keyof E, E[keyof E]>>} entries
*/
toContainAllEntries<E = any>(entries: ReadonlyArray<readonly [keyof E, E[keyof E]]>): R;
toContainAllEntries<E = any>(entries: readonly (readonly [keyof E, E[keyof E]])[]): R;

/**
* Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries.
*
* @param {Array.<Array.<keyof E, E[keyof E]>>} entries
*/
toContainAnyEntries<E = any>(entries: ReadonlyArray<readonly [keyof E, E[keyof E]]>): R;
toContainAnyEntries<E = any>(entries: readonly (readonly [keyof E, E[keyof E]])[]): R;

/**
* Use `.toBeExtensible` when checking if an object is extensible.
Expand Down Expand Up @@ -387,7 +387,7 @@ declare namespace jest {
* @param {Function} type
* @param {String | RegExp} message
*/
toThrowWithMessage(type: Function, message: string | RegExp): R;
toThrowWithMessage(type: (...args: unknown[]) => unknown, message: string | RegExp): R;

/**
* Use `.toBeEmptyObject` when checking if a value is an empty `Object`.
Expand Down Expand Up @@ -650,21 +650,21 @@ declare namespace jest {
*
* @param {Array.<String>} keys
*/
toContainKeys<E = any>(keys: ReadonlyArray<keyof E | string>): any;
toContainKeys<E = any>(keys: readonly (keyof E | string)[]): any;

/**
* Use `.toContainAllKeys` when checking if an object only contains all of the provided keys.
*
* @param {Array.<String>} keys
*/
toContainAllKeys<E = any>(keys: ReadonlyArray<keyof E | string>): any;
toContainAllKeys<E = any>(keys: readonly (keyof E | string)[]): any;

/**
* Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys.
*
* @param {Array.<String>} keys
*/
toContainAnyKeys<E = any>(keys: ReadonlyArray<keyof E | string>): any;
toContainAnyKeys<E = any>(keys: readonly (keyof E | string)[]): any;

/**
* Use `.toContainValue` when checking if an object contains the provided value.
Expand Down Expand Up @@ -706,21 +706,21 @@ declare namespace jest {
*
* @param {Array.<Array.<keyof E, E[keyof E]>>} entries
*/
toContainEntries<E = any>(entries: ReadonlyArray<readonly [keyof E, E[keyof E]]>): any;
toContainEntries<E = any>(entries: readonly (readonly [keyof E, E[keyof E]])[]): any;

/**
* Use `.toContainAllEntries` when checking if an object only contains all of the provided entries.
*
* @param {Array.<Array.<keyof E, E[keyof E]>>} entries
*/
toContainAllEntries<E = any>(entries: ReadonlyArray<readonly [keyof E, E[keyof E]]>): any;
toContainAllEntries<E = any>(entries: readonly (readonly [keyof E, E[keyof E]])[]): any;

/**
* Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries.
*
* @param {Array.<Array.<keyof E, E[keyof E]>>} entries
*/
toContainAnyEntries<E = any>(entries: ReadonlyArray<readonly [keyof E, E[keyof E]]>): any;
toContainAnyEntries<E = any>(entries: readonly (readonly [keyof E, E[keyof E]])[]): any;

/**
* Use `.toBeExtensible` when checking if an object is extensible.
Expand Down Expand Up @@ -801,7 +801,7 @@ declare namespace jest {
* @param {Function} type
* @param {String | RegExp} message
*/
toThrowWithMessage(type: Function, message: string | RegExp): any;
toThrowWithMessage(type: (...args: unknown[]) => unknown, message: string | RegExp): any;

/**
* Use `.toBeEmptyObject` when checking if a value is an empty `Object`.
Expand Down
Loading

0 comments on commit 49ceff9

Please sign in to comment.