Skip to content

Commit 38fdb13

Browse files
committed
style: added prettier and re-format the code
1 parent 2085998 commit 38fdb13

7 files changed

+1621
-34
lines changed

.eslintrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true,
6+
"jest/globals": true
7+
},
8+
"extends": ["plugin:jest/recommended", "plugin:prettier/recommended"],
9+
"plugins": ["jest", "prettier"]
10+
}

.prettierrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
printWidth: 120,
3+
tabWidth: 2,
4+
semi: true,
5+
singleQuote: true,
6+
bracketSpacing: true,
7+
arrowParens: 'avoid',
8+
endOfLine: 'lf',
9+
};

commitlint.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
rules: {
3+
'body-leading-blank': [1, 'always'],
4+
'footer-leading-blank': [1, 'always'],
5+
'header-max-length': [2, 'always', 72],
6+
'scope-case': [2, 'always', 'lower-case'],
7+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
8+
'subject-empty': [2, 'never'],
9+
'subject-full-stop': [2, 'never', '.'],
10+
'type-case': [2, 'always', 'lower-case'],
11+
'type-empty': [2, 'never'],
12+
'type-enum': [
13+
2,
14+
'always',
15+
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test'],
16+
],
17+
},
18+
};

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ function GraphQLTagPrintedLoader(src) {
3030
}
3131

3232
return newSource + os.EOL;
33-
};
33+
}
3434

3535
// Makes it work with Jest as well
36-
GraphQLTagPrintedLoader.process = (src) => {
37-
return GraphQLTagPrintedLoader.call({ cacheable() { } }, src);
36+
GraphQLTagPrintedLoader.process = src => {
37+
return GraphQLTagPrintedLoader.call({ cacheable() {} }, src);
3838
};
3939

4040
module.exports = GraphQLTagPrintedLoader;

jest.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
rootDir: __dirname,
33
testMatch: ['<rootDir>/tests/**/*spec.[jt]s?(x)'],
4-
"transform": {
5-
"\\.(gql|graphql)$": __dirname + '/index.js',
6-
}
4+
transform: {
5+
'\\.(gql|graphql)$': __dirname + '/index.js',
6+
},
77
};

package.json

+28-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,40 @@
66
"author": "Abdelrahman Awad",
77
"license": "MIT",
88
"scripts": {
9-
"test": "jest"
9+
"test": "jest",
10+
"lint": "eslint . '**/*.{js,jsx,ts,tsx}' --fix",
11+
"format": "prettier \"./**/*.js\" --write"
1012
},
13+
"files": [
14+
"index.js"
15+
],
1116
"dependencies": {
1217
"eval": "^0.1.4",
1318
"graphql": "^15.0.0",
1419
"graphql-tag": "^2.10.3"
1520
},
1621
"devDependencies": {
17-
"jest": "^26.0.1"
22+
"@commitlint/cli": "^8.3.5",
23+
"eslint": "^7.0.0",
24+
"eslint-config-prettier": "^6.11.0",
25+
"eslint-plugin-jest": "^23.13.1",
26+
"eslint-plugin-prettier": "^3.1.3",
27+
"husky": "^4.2.5",
28+
"jest": "^26.0.1",
29+
"lint-staged": "^10.2.4",
30+
"prettier": "^2.0.5"
31+
},
32+
"husky": {
33+
"hooks": {
34+
"pre-commit": "lint-staged",
35+
"commit-msg": "commitlint --edit -E HUSKY_GIT_PARAMS"
36+
}
37+
},
38+
"lint-staged": {
39+
"*.js": [
40+
"eslint --fix",
41+
"prettier --write",
42+
"jest --maxWorkers=1 --bail --findRelatedTests"
43+
]
1844
}
1945
}

0 commit comments

Comments
 (0)