Skip to content

Commit b130f1d

Browse files
chore: add prettier
1 parent da87e9e commit b130f1d

File tree

297 files changed

+2297
-2977
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+2297
-2977
lines changed

.eslintrc

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
2-
"extends": [
3-
"plugin:@typescript-eslint/recommended"
4-
],
2+
"extends": ["plugin:@typescript-eslint/recommended"],
53
"parser": "@typescript-eslint/parser",
6-
"plugins": ["import", "@typescript-eslint", "mocha"],
4+
"plugins": ["import", "@typescript-eslint", "mocha", "prettier"],
75
"parserOptions": {
86
"ecmaVersion": 8
97
},
@@ -49,7 +47,7 @@
4947
{
5048
"files": ["test/**/*.js"],
5149
"rules": {
52-
"@typescript-eslint/no-var-requires": "off"
50+
"@typescript-eslint/no-var-requires": "off"
5351
}
5452
}
5553
],
@@ -132,32 +130,31 @@
132130
"space-in-parens": ["error", "never"],
133131
"spaced-comment": ["error", "always"],
134132

135-
"import/order": ["error", {
136-
"alphabetize": {
137-
"order": "asc",
138-
"caseInsensitive": false
139-
},
140-
"groups": [
141-
"builtin",
142-
"external",
143-
"internal",
144-
"parent",
145-
"sibling",
146-
"index"
147-
],
148-
"newlines-between": "always-and-inside-groups"
149-
}],
133+
"import/order": [
134+
"error",
135+
{
136+
"alphabetize": {
137+
"order": "asc",
138+
"caseInsensitive": false
139+
},
140+
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
141+
"newlines-between": "always-and-inside-groups"
142+
}
143+
],
150144

151145
"@typescript-eslint/ban-types": ["off"],
152146
"@typescript-eslint/class-name-casing": ["error"],
153-
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
147+
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
154148
"@typescript-eslint/generic-type-naming": ["error", "^T(?:[A-Z][a-zA-Z]+)*$"],
155149
"@typescript-eslint/indent": ["off"],
156-
"@typescript-eslint/member-delimiter-style": ["error", { "multiline": { "delimiter": "none"} }],
150+
"@typescript-eslint/member-delimiter-style": ["error", { "multiline": { "delimiter": "none" } }],
157151
"@typescript-eslint/no-inferrable-types": ["error", { "ignoreParameters": true, "ignoreProperties": true }],
158152
"@typescript-eslint/no-explicit-any": ["off"],
159153
"@typescript-eslint/no-unused-vars": ["error"],
160-
"@typescript-eslint/no-use-before-define": ["error", { "functions": false, "classes": false, "variables": true, "enums": true }],
154+
"@typescript-eslint/no-use-before-define": [
155+
"error",
156+
{ "functions": false, "classes": false, "variables": true, "enums": true }
157+
],
161158
"@typescript-eslint/semi": ["error", "never"]
162159
}
163160
}

.mocharc.js

+14-47
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,40 @@
1-
// extension:
2-
// - ts
3-
// require:
4-
// - 'tsconfig-paths/register'
5-
// - './test/ts-node.js'
6-
// - 'ts-custom-error-shim'
7-
// - './test/mocha.config'
8-
// - 'test/sandbox.ts'
9-
// ignore:
10-
// - node_modules
11-
// spec:
12-
// - 'packages/*/*/{,(!node_modules)/}index.ts'
13-
// - 'packages/*/*/{,(!node_modules)/*/}*/index.ts'
14-
// - 'packages/*/*/{,(!node_modules)/}src/**/*.spec.ts'
15-
// - 'packages/*/*/{,(!node_modules)/*/}*/src/**/*.spec.ts'
16-
// - 'packages/*/*/{,(!node_modules)/}src/**/*.int-spec.ts'
17-
// - 'packages/*/*/{,(!node_modules)/*/}*/src/**/*.int-spec.ts'
18-
191
const { readdirSync, statSync } = require('fs')
202
const { dirname, resolve } = require('path')
213

22-
const [,, scopesArg, ...scopes] = process.argv
4+
const [, , scopesArg, ...scopes] = process.argv
235
if (scopesArg !== '--scope') {
246
scopes.length = 0
257
}
268

27-
const manifest = require('./.tsconfig.builder.json').include.filter(file => file.endsWith('index.ts'))
9+
const manifest = require('./.tsconfig.builder.json').include.filter((file) => file.endsWith('index.ts'))
2810
function findPaths(dir) {
2911
const subDirs = readdirSync(dir)
3012
return subDirs
31-
.filter(subDir => subDir !== 'src' && subDir !== 'node_modules' && subDir !== '.yarn-cache')
32-
.map(subDir => `${dir}/${subDir}`)
33-
.filter(subDir => statSync(subDir).isDirectory())
13+
.filter((subDir) => subDir !== 'src' && subDir !== 'node_modules' && subDir !== '.yarn-cache')
14+
.map((subDir) => `${dir}/${subDir}`)
15+
.filter((subDir) => statSync(subDir).isDirectory())
3416
.reduce((result, subDir) => {
3517
result.push(subDir)
3618
result.push(...findPaths(subDir))
3719
return result
3820
}, [])
3921
}
4022
const paths = manifest
41-
.filter(path => {
23+
.filter((path) => {
4224
if (!scopes.length) {
4325
return true
4426
}
45-
return scopes.some(scope => path.startsWith(`packages/${scope}/`))
27+
return scopes.some((scope) => path.startsWith(`packages/${scope}/`))
4628
})
4729
.reduce((result, file) => {
4830
const dir = dirname(file)
4931
result.push(dir, ...findPaths(resolve(__dirname, dir)))
5032
return result
5133
}, [])
52-
const barrels = paths.map(path => `${path}/index.ts`)
53-
const unitSpec = paths.map(path => `${path}/src/**/*.spec.ts`)
54-
const intSpec = paths.map(path => `${path}/src/**/*.int-spec.ts`)
55-
const spec = [
56-
...barrels,
57-
...unitSpec,
58-
...intSpec,
59-
]
34+
const barrels = paths.map((path) => `${path}/index.ts`)
35+
const unitSpec = paths.map((path) => `${path}/src/**/*.spec.ts`)
36+
const intSpec = paths.map((path) => `${path}/src/**/*.int-spec.ts`)
37+
const spec = [...barrels, ...unitSpec, ...intSpec]
6038

6139
// suppress "Cannot find any files matching pattern" warnings from mocha startup
6240
console.__ogWarn = console.warn
@@ -69,25 +47,14 @@ console.warn = (msg, ...args) => {
6947

7048
module.exports = {
7149
extension: 'ts',
72-
ignore: [
73-
'.out',
74-
'.build',
75-
'dist',
76-
],
77-
watchIgnore: [
78-
'.out',
79-
'.build',
80-
'dist',
81-
],
50+
ignore: ['.out', '.build', 'dist'],
51+
watchIgnore: ['.out', '.build', 'dist'],
8252
require: [
8353
'tsconfig-paths/register',
8454
resolve(__dirname, './test/ts-node.js'),
8555
'ts-custom-error-shim',
8656
resolve(__dirname, './test/mocha.config'),
8757
],
88-
file: [
89-
resolve(__dirname, 'test/sandbox.ts'),
90-
...manifest,
91-
],
58+
file: [resolve(__dirname, 'test/sandbox.ts'), ...manifest],
9259
spec,
9360
}

.prettierignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.coverage
2+
.modules
3+
.nyc_output
4+
.prettierignore
5+
.yarn-cache
6+
*.pug
7+
*.tf
8+
node_modules
9+
out
10+
yarn.lock

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 120,
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "all"
6+
}

.travis.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ cache:
1616
- packages/dandi-contrib/mvc-view-pug/node_modules
1717

1818
install:
19-
- "yarn setup"
20-
- "yarn tsc --version"
21-
- "yarn ts-node --version"
19+
- 'yarn setup'
20+
- 'yarn tsc --version'
21+
- 'yarn ts-node --version'
2222

2323
script:
24-
- "yarn build"
25-
- "yarn coverage"
24+
- 'yarn build'
25+
- 'yarn coverage'
2626

2727
after_script:
28-
- "yarn coverage-report"
28+
- 'yarn coverage-report'

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ the features they require.
1313
[Get Started](./packages/dandi/core)
1414

1515
## Use Cases
16+
1617
- MVC-style Application Servers
1718
- CLI Applications
1819
- AWS Lambda functions
@@ -32,7 +33,7 @@ the features they require.
3233
- Automatic output content negotiation based on request `accept` header
3334
- Create and configure interdependent middleware handlers (`HttpPipelinePreparer`) and they will automatically be
3435
invoked in the correct order
35-
- Add global transformers to control response data structure
36+
- Add global transformers to control response data structure
3637

3738
### MVC
3839

@@ -104,7 +105,8 @@ implementation of a very simple REST API using `@dandi`
104105
## Dev Setup
105106

106107
To set up this project as a local repository:
108+
107109
- [Install Yarn Classic](https://classic.yarnpkg.com/en/docs/install) if you don't have it installed
108110
- After cloning the repostory, run `yarn setup` - this will install the dependencies for all the individual packages,
109-
as well as the Dandi builder
110-
- You can now run `yarn build` to build all packages, or `yarn test` to run all tests
111+
as well as the Dandi builder
112+
- You can now run `yarn build` to build all packages, or `yarn test` to run all tests

_config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
theme: jekyll-theme-minimal
1+
theme: jekyll-theme-minimal

_examples/simple-aws-lambda/serverless.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ plugins:
6565
functions:
6666
helloWorld:
6767
handler: main.helloWorldHandler
68-
# The following are a few example events you can configure
69-
# NOTE: Please make sure to change your handler code to work with those events
70-
# Check the event documentation for details
68+
# The following are a few example events you can configure
69+
# NOTE: Please make sure to change your handler code to work with those events
70+
# Check the event documentation for details
7171
events:
7272
- http:
7373
path: hello-world

_examples/simple-aws-lambda/src/data-processor.service.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ const FAKE_LATENCY = 250
66

77
@Injectable()
88
export class DataProcessorService {
9-
109
public processData(data: ReceiveDataModel): Promise<ReceiveDataResponse> {
11-
return new Promise<ReceiveDataResponse>(resolve => {
10+
return new Promise<ReceiveDataResponse>((resolve) => {
1211
setTimeout(() => resolve(this.convertData(data)), FAKE_LATENCY)
1312
})
1413
}
@@ -19,5 +18,4 @@ export class DataProcessorService {
1918
modelType: data.constructor.name,
2019
}
2120
}
22-
2321
}

_examples/simple-aws-lambda/src/hello-world.handler.ts

-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import { QueryParam } from '@dandi/http-model'
44

55
@Injectable()
66
export class HelloWorldHandler implements LambdaHandler {
7-
87
public handleEvent(@QueryParam(Number) foo: string): any {
98
return {
109
message: 'hello!',
1110
foo,
1211
}
1312
}
14-
1513
}

_examples/simple-aws-lambda/src/receive-data.handler.spec.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ import { ReceiveDataHandler } from './receive-data.handler'
1010
import { ReceiveDataResponse } from './receive-data.model'
1111

1212
describe('ReceiveDataHandler', () => {
13-
1413
let classUnderTest: ReceiveDataHandler
1514
let body: any
1615
let request: HttpRequest
1716

18-
const harness = testHarness(ReceiveDataHandler,
19-
DataProcessorService,
20-
ModelBuilderModule,
21-
{
22-
provide: HttpRequest,
23-
useFactory: () => request,
24-
},
25-
)
17+
const harness = testHarness(ReceiveDataHandler, DataProcessorService, ModelBuilderModule, {
18+
provide: HttpRequest,
19+
useFactory: () => request,
20+
})
2621

2722
beforeEach(async () => {
2823
body = {
@@ -45,7 +40,6 @@ describe('ReceiveDataHandler', () => {
4540

4641
describe('handleEvent', () => {
4742
it('converts the incoming model to the response model', async () => {
48-
4943
const result: ReceiveDataResponse = await harness.invoke(classUnderTest, 'handleEvent')
5044

5145
expect(result).to.haveOwnProperty('model')
@@ -55,8 +49,6 @@ describe('ReceiveDataHandler', () => {
5549
message: 'hi!',
5650
})
5751
expect(result.modelType).to.equal('ReceiveDataModel')
58-
5952
})
6053
})
61-
6254
})

_examples/simple-aws-lambda/src/receive-data.handler.ts

-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import { ReceiveDataModel, ReceiveDataResponse } from './receive-data.model'
77

88
@Injectable()
99
export class ReceiveDataHandler implements LambdaHandler {
10-
1110
constructor(@Inject(DataProcessorService) private processor: DataProcessorService) {}
1211

1312
public handleEvent(@RequestBody(ReceiveDataModel) data: ReceiveDataModel): Promise<ReceiveDataResponse> {
1413
return this.processor.processData(data)
1514
}
16-
1715
}

_examples/simple-console/cli.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import * as program from 'commander'
77
import { run } from './src/main'
88
import { PACKAGE_VERSION } from './src/package'
99

10-
program
11-
.version(PACKAGE_VERSION)
12-
.usage('[options]')
13-
.parse(process.argv)
10+
program.version(PACKAGE_VERSION).usage('[options]').parse(process.argv)
1411

1512
run(start, program)
16-

_examples/simple-console/src/app-options.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@ import { InjectionToken, Provider } from '@dandi/core'
33
import { localOpinionatedToken } from './local-token'
44

55
// eslint-disable-next-line @typescript-eslint/no-empty-interface
6-
export interface AppOptions {
7-
}
6+
export interface AppOptions {}
87

98
// eslint-disable-next-line @typescript-eslint/no-empty-interface
10-
export interface AppConfig {
11-
}
9+
export interface AppConfig {}
1210

1311
export const AppConfig: InjectionToken<AppConfig> = localOpinionatedToken('AppConfig', {
1412
multi: false,
1513
})
1614

1715
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1816
export function installerConfigFactory(options: AppConfig): AppConfig {
19-
return {
20-
}
17+
return {}
2118
}
2219

2320
export function appConfigProvider(options: AppOptions): Provider<AppConfig> {

_examples/simple-console/src/app.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const SIM_FAKE_WORK_TIMEOUT = 50
55

66
@Injectable(EntryPoint)
77
export class SimpleConsoleApp implements EntryPoint {
8-
98
constructor(@Inject(Logger) private logger: Logger) {}
109

1110
public async run(): Promise<void> {
@@ -26,7 +25,6 @@ export class SimpleConsoleApp implements EntryPoint {
2625
}
2726

2827
private fakeWork(timeout: number): Promise<void> {
29-
return new Promise(resolve => setTimeout(resolve, timeout))
28+
return new Promise((resolve) => setTimeout(resolve, timeout))
3029
}
31-
3230
}

0 commit comments

Comments
 (0)