Add linting

This commit is contained in:
Todd Baert 2022-05-11 13:11:14 -04:00
parent c9b9d8d3a5
commit dac783faa8
No known key found for this signature in database
GPG Key ID: 6832CDB677D5E06D
8 changed files with 287 additions and 9 deletions

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
node_modules
dist

33
.eslintrc.json Normal file
View File

@ -0,0 +1,33 @@
{
"env":{
"browser":true,
"es2021":true
},
"extends":[
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser":"@typescript-eslint/parser",
"parserOptions":{
"ecmaVersion":"latest",
"sourceType":"module"
},
"plugins":[
"@typescript-eslint"
],
"rules":{
"linebreak-style":[
"error",
"unix"
],
"quotes":[
"error",
"single"
],
"semi":[
"error",
"always"
]
}
}

View File

@ -0,0 +1,3 @@
{
"singleQuote": true
}

8
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}

View File

@ -23,7 +23,7 @@ export default {
// collectCoverageFrom: undefined,
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
coverageDirectory: 'coverage',
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
@ -31,7 +31,7 @@ export default {
// ],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
coverageProvider: 'v8',
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
@ -100,7 +100,7 @@ export default {
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
preset: "ts-jest",
preset: 'ts-jest',
// Run tests from one or more projects
// projects: undefined,
@ -144,7 +144,7 @@ export default {
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "node",
testEnvironment: 'node',
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

229
package-lock.json generated
View File

@ -1020,6 +1020,151 @@
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==",
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.23.0.tgz",
"integrity": "sha512-hEcSmG4XodSLiAp1uxv/OQSGsDY6QN3TcRU32gANp+19wGE1QQZLRS8/GV58VRUoXhnkuJ3ZxNQ3T6Z6zM59DA==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.23.0",
"@typescript-eslint/type-utils": "5.23.0",
"@typescript-eslint/utils": "5.23.0",
"debug": "^4.3.2",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.1.8",
"regexpp": "^3.2.0",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
},
"dependencies": {
"@typescript-eslint/scope-manager": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz",
"integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0"
}
},
"@typescript-eslint/types": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz",
"integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz",
"integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/utils": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.23.0.tgz",
"integrity": "sha512-dbgaKN21drqpkbbedGMNPCtRPZo1IOUr5EI9Jrrh99r5UW5Q0dz46RKXeSBoPV+56R6dFKpbrdhgUNSJsDDRZA==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.23.0",
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/typescript-estree": "5.23.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz",
"integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"eslint-visitor-keys": "^3.0.0"
}
},
"eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
"dev": true,
"requires": {
"esrecurse": "^4.3.0",
"estraverse": "^4.1.1"
}
},
"estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true
}
}
},
"@typescript-eslint/parser": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.23.0.tgz",
"integrity": "sha512-V06cYUkqcGqpFjb8ttVgzNF53tgbB/KoQT/iB++DOIExKmzI9vBJKjZKt/6FuV9c+zrDsvJKbJ2DOCYwX91cbw==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.23.0",
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/typescript-estree": "5.23.0",
"debug": "^4.3.2"
},
"dependencies": {
"@typescript-eslint/scope-manager": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz",
"integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0"
}
},
"@typescript-eslint/types": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz",
"integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz",
"integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz",
"integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"eslint-visitor-keys": "^3.0.0"
}
}
}
},
"@typescript-eslint/scope-manager": {
"version": "5.22.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.22.0.tgz",
@ -1030,6 +1175,90 @@
"@typescript-eslint/visitor-keys": "5.22.0"
}
},
"@typescript-eslint/type-utils": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.23.0.tgz",
"integrity": "sha512-iuI05JsJl/SUnOTXA9f4oI+/4qS/Zcgk+s2ir+lRmXI+80D8GaGwoUqs4p+X+4AxDolPpEpVUdlEH4ADxFy4gw==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.23.0",
"debug": "^4.3.2",
"tsutils": "^3.21.0"
},
"dependencies": {
"@typescript-eslint/scope-manager": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz",
"integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0"
}
},
"@typescript-eslint/types": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz",
"integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz",
"integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/utils": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.23.0.tgz",
"integrity": "sha512-dbgaKN21drqpkbbedGMNPCtRPZo1IOUr5EI9Jrrh99r5UW5Q0dz46RKXeSBoPV+56R6dFKpbrdhgUNSJsDDRZA==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.23.0",
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/typescript-estree": "5.23.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz",
"integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"eslint-visitor-keys": "^3.0.0"
}
},
"eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
"dev": true,
"requires": {
"esrecurse": "^4.3.0",
"estraverse": "^4.1.1"
}
},
"estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true
}
}
},
"@typescript-eslint/types": {
"version": "5.22.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.22.0.tgz",

View File

@ -6,6 +6,7 @@
"types": "./dist/types/index.d.ts",
"scripts": {
"test": "jest",
"lint": "eslint ./",
"postbuild": "cp ./package.esm.json ./dist/esm/package.json",
"build": "rm -R ./dist && tsc --project tsconfig.json && tsc --project tsconfig.cjs.json"
},
@ -38,6 +39,8 @@
"devDependencies": {
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^26.1.5",

View File

@ -1,8 +1,8 @@
import { greet } from "../src/index";
import { greet } from '../src/index';
describe("greet", () => {
it("should return greeting", () => {
const result = greet("hi");
expect(result).toEqual("hi");
describe('greet', () => {
it('should return greeting', () => {
const result = greet('hi');
expect(result).toEqual('hi');
});
});