Skip to content

Commit ebe74fa

Browse files
committed
feat: code-standard-preset
1 parent c9c0c45 commit ebe74fa

13 files changed

+1296
-861
lines changed

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./node_modules/@sofie-automation/code-standard-preset/eslint/main"
3+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md

config/tsconfig.base.json

-37
This file was deleted.

config/tsconfig.flexible.json

-5
This file was deleted.

config/tsconfig.strict.json

-15
This file was deleted.

jest.config.js

+15-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
module.exports = {
22
globals: {
3-
'ts-jest': {
4-
tsConfig: 'tsconfig.json'
5-
}
3+
"ts-jest": {
4+
tsconfig: "tsconfig.json",
5+
},
66
},
7-
moduleFileExtensions: [
8-
'ts',
9-
'js'
10-
],
7+
moduleFileExtensions: ["ts", "js"],
118
transform: {
12-
'^.+\\.(ts|tsx)$': 'ts-jest'
9+
"^.+\\.(ts|tsx)$": "ts-jest",
1310
},
14-
testMatch: [
15-
'**/__tests__/**/*.spec.(ts|js)'
16-
],
17-
testPathIgnorePatterns: [
18-
'integrationTests'
19-
],
20-
testEnvironment: 'node',
11+
testMatch: ["**/__tests__/**/*.spec.(ts|js)"],
12+
testPathIgnorePatterns: ["integrationTests"],
13+
testEnvironment: "node",
2114
coverageThreshold: {
2215
global: {
23-
branches: 0,
24-
functions: 0,
25-
lines: 0,
26-
statements: 0
27-
}
16+
branches: 0,
17+
functions: 0,
18+
lines: 0,
19+
statements: 0,
20+
},
2821
},
2922
coverageDirectory: "./coverage/",
30-
collectCoverage: true
31-
}
23+
collectCoverage: true,
24+
};

package.json

+22-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"info": "npm-scripts-info",
3333
"build": "rimraf dist && yarn build:main",
3434
"build:main": "tsc -p tsconfig.build.json",
35-
"lint": "tslint --project tsconfig.json --config tslint.json",
35+
"lint": "eslint . --ext .ts --ext .js --ext .tsx --ext .jsx --ignore-pattern dist",
36+
"lint-fix": "yarn lint --fix",
3637
"unit": "jest --forceExit",
3738
"test": "yarn lint && yarn unit",
3839
"test:integration": "yarn lint && jest --config=jest-integration.config.js",
@@ -42,15 +43,15 @@
4243
"send-coverage": "codecov",
4344
"docs": "yarn docs:html && open-cli docs/index.html",
4445
"docs:test": "yarn docs:html",
45-
"docs:html": "typedoc src/index.ts --excludePrivate --mode file --theme minimal --out docs",
46-
"docs:json": "typedoc --mode file --json docs/typedoc.json src/index.ts",
46+
"docs:html": "typedoc src/index.ts --excludePrivate --theme minimal --out docs",
47+
"docs:json": "typedoc --json docs/typedoc.json src/index.ts",
4748
"docs:publish": "yarn docs:html && gh-pages -d docs",
4849
"changelog": "standard-version",
4950
"release": "yarn reset && yarn test && yarn docs:publish && yarn changelog",
5051
"reset": "git clean -dfx && git reset --hard && yarn",
5152
"validate:dependencies": "yarn audit --groups dependencies && yarn license-validate",
5253
"validate:dev-dependencies": "yarn audit --groups devDependencies",
53-
"license-validate": "node-license-validator -p -d --allow-licenses MIT BSD 0BSD BSD-3-Clause ISC Apache Unlicense"
54+
"license-validate": "yarn sofie-licensecheck"
5455
},
5556
"scripts-info": {
5657
"info": "Display information about the scripts",
@@ -85,24 +86,20 @@
8586
"/LICENSE"
8687
],
8788
"devDependencies": {
89+
"@sofie-automation/code-standard-preset": "^0.2.4",
8890
"@types/jest": "^26.0.22",
8991
"@types/node": "^12.11.2",
9092
"@types/underscore": "^1.11.1",
9193
"codecov": "^3.8.1",
9294
"gh-pages": "^3.1.0",
9395
"jest": "^26.6.3",
94-
"jest-haste-map": "^26.6.2",
95-
"jest-resolve": "^26.6.2",
96-
"node-license-validator": "^1.3.0",
9796
"npm-scripts-info": "0.3.9",
9897
"open-cli": "^6",
9998
"rimraf": "^3.0.2",
10099
"standard-version": "^9.2.0",
101100
"ts-jest": "^26.5.5",
102-
"tslint": "^6.1.3",
103-
"tslint-config-standard": "9.0.0",
104-
"typedoc": "^0.15.0",
105-
"typescript": "~4.2.4"
101+
"typedoc": "^0.20.35",
102+
"typescript": "~4.0.5"
106103
},
107104
"keywords": [
108105
"typescript",
@@ -118,5 +115,19 @@
118115
"standard-version": {
119116
"message": "chore(release): %s [skip ci]",
120117
"tagPrefix": ""
118+
},
119+
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
120+
"husky": {
121+
"hooks": {
122+
"pre-commit": "lint-staged"
123+
}
124+
},
125+
"lint-staged": {
126+
"*.{css,json,md,scss}": [
127+
"prettier --write"
128+
],
129+
"*.{ts,tsx,js,jsx}": [
130+
"yarn lint-fix"
131+
]
121132
}
122133
}

src/__tests__/enums.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as _ from 'lodash'
1+
import * as _ from 'underscore'
22
import { Enums } from '../'
33
import { Enums as ConnEnums } from 'atem-connection'
44

tsconfig.build.json

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
{
2-
"extends": "./config/tsconfig.base",
3-
"exclude": [
4-
"node_modules/**",
5-
"src/**/*spec.ts",
6-
"src/**/__mocks__/*"
7-
]
2+
"extends": "@sofie-automation/code-standard-preset/ts/tsconfig.lib",
3+
"include": ["src/**/*.ts"],
4+
"exclude": [
5+
"node_modules/**",
6+
"src/**/*spec.ts",
7+
"src/**/__tests__/*",
8+
"src/**/__mocks__/*"
9+
],
10+
"compilerOptions": {
11+
"outDir": "./dist",
12+
"baseUrl": "./",
13+
"paths": {
14+
"*": ["./node_modules/*"],
15+
"{{PACKAGE-NAME}}": ["./src/index.ts"]
16+
},
17+
"types": ["node"]
18+
}
819
}

tsconfig.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"extends": "./config/tsconfig.base",
3-
"exclude": [
4-
"node_modules/**"
5-
]
6-
}
2+
"extends": "./tsconfig.build.json",
3+
"exclude": ["node_modules/**"],
4+
"compilerOptions": {
5+
"types": ["jest", "node"]
6+
}
7+
}

tslint.json

-9
This file was deleted.

0 commit comments

Comments
 (0)