Skip to content

Commit 4414757

Browse files
committed
chore: fixed formatting
added prettier
1 parent 4b2d29f commit 4414757

12 files changed

+184
-61
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib/
2+
node_modules/
3+
coverage/
4+
.idea/

.eslintrc.json

-37
This file was deleted.

.eslintrc.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
parser: '@typescript-eslint/parser'
2+
extends:
3+
- plugin:@typescript-eslint/recommended
4+
- plugin:prettier/recommended
5+
6+
plugins:
7+
- simple-import-sort
8+
9+
parserOptions:
10+
ecmaVersion: 2020
11+
sourceType: module
12+
13+
rules:
14+
quotes:
15+
- error
16+
- single
17+
- avoidEscape: true
18+
allowTemplateLiterals: true
19+
simple-import-sort/imports: error
20+
simple-import-sort/exports: error

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ dist
105105

106106
# IDEA
107107
.idea/
108+
109+
# Build
110+
/lib/

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid"
10+
}

jest.config.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ const config: Config = {
55
rootDir: 'src',
66
testRegex: '.*\\.spec\\.ts$',
77
transform: {
8-
'^.+\\.(t|j)s$': 'ts-jest',
8+
'^.+\\.(t|j)s$': 'ts-jest'
99
},
1010
coverageThreshold: {
1111
global: {
1212
branches: 100,
1313
functions: 100,
1414
lines: 100,
15-
statements: 100,
16-
},
15+
statements: 100
16+
}
1717
},
1818
collectCoverageFrom: ['**/*.ts'],
1919
coveragePathIgnorePatterns: ['/node_modules/'],
2020
coverageDirectory: '../coverage',
21-
testEnvironment: 'node',
22-
};
21+
testEnvironment: 'node'
22+
}
2323

2424
// noinspection JSUnusedGlobalSymbols
25-
export default config;
25+
export default config

package-lock.json

+123
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"description": "Java properties file parser and formatter for Javascript.",
55
"scripts": {
6-
"lint": "eslint 'src/**/*.ts'",
6+
"lint": "eslint .",
77
"fix": "npm run lint -- --fix",
88
"prebuild": "rimraf lib",
99
"build": "tsc --project tsconfig.build.json",
@@ -30,13 +30,22 @@
3030
"engines": {
3131
"node": ">= 14"
3232
},
33+
"main": "lib/properties.js",
34+
"files": [
35+
"lib",
36+
"src"
37+
],
3338
"devDependencies": {
3439
"@jest/types": "^29.5.0",
3540
"@types/jest": "^29.5.0",
3641
"@typescript-eslint/eslint-plugin": "^5.55.0",
3742
"@typescript-eslint/parser": "^5.55.0",
3843
"eslint": "^8.36.0",
44+
"eslint-config-prettier": "^8.7.0",
45+
"eslint-plugin-prettier": "^4.2.1",
46+
"eslint-plugin-simple-import-sort": "^10.0.0",
3947
"jest": "^29.5.0",
48+
"prettier": "^2.8.4",
4049
"rimraf": "^4.4.0",
4150
"ts-jest": "^29.0.5",
4251
"ts-node": "^10.9.1",

src/properties.spec.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ describe('stringify', () => {
2424

2525
// Test
2626
const result = properties.stringify(config)
27-
expect(result).toEqual(
28-
'registry=https://abcd\n#foo bar\n@scope:test=avx\n'
29-
)
27+
expect(result).toEqual('registry=https://abcd\n#foo bar\n@scope:test=avx\n')
3028
})
3129

3230
it('should remove leading newlines', () => {
@@ -243,13 +241,7 @@ describe('data access', () => {
243241

244242
it('should return last value of duplicate key', () => {
245243
const config: properties.Properties = {
246-
lines: [
247-
'foo=bar1',
248-
'a=b',
249-
'foo=bar2',
250-
'foo=bar3',
251-
'c=d'
252-
]
244+
lines: ['foo=bar1', 'a=b', 'foo=bar2', 'foo=bar3', 'c=d']
253245
}
254246

255247
const result = properties.toMap(config)

src/properties.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const remove = (config: Properties, key: string): void =>
156156
const findValue = (
157157
lines: string[],
158158
key: string
159-
): { start: number; len: number; sep: string; rawValue?: string } => {
159+
): {start: number; len: number; sep: string; rawValue?: string} => {
160160
let sep = '='
161161
for (const entry of listPairs(lines)) {
162162
// Remember separator
@@ -230,7 +230,7 @@ const countEndChars = (str: string, c: string): number => {
230230

231231
const parseLine = (
232232
line: string
233-
): { key: string; valueLine: string; sep: string } => {
233+
): {key: string; valueLine: string; sep: string} => {
234234
let i = -1
235235

236236
// Skip start spaces

tsconfig.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
"strict": true,
99
"sourceMap": true,
1010
"declaration": true,
11-
"allowSyntheticDefaultImports": true,
12-
"experimentalDecorators": true,
13-
"emitDecoratorMetadata": true,
14-
"outDir": "lib",
15-
"esModuleInterop": true,
11+
"outDir": "lib"
1612
},
1713
"include": [
1814
"src"

0 commit comments

Comments
 (0)