Skip to content

Commit 6290cdc

Browse files
authored
Merge pull request #3 from Code-Hex/add/eslint
add eslint
2 parents 7632618 + 55d2690 commit 6290cdc

File tree

7 files changed

+470
-35
lines changed

7 files changed

+470
-35
lines changed

.eslintrc.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"parser": "@typescript-eslint/parser",
11+
"parserOptions": {
12+
"ecmaVersion": "latest"
13+
},
14+
"plugins": [
15+
"@typescript-eslint"
16+
],
17+
"rules": {
18+
"@typescript-eslint/no-explicit-any": "off"
19+
},
20+
"overrides": [
21+
{
22+
"files": [
23+
"*.spec.ts"
24+
],
25+
"env": {
26+
"jest": true
27+
},
28+
"rules": {
29+
"no-unused-vars": "off",
30+
"@typescript-eslint/no-unused-vars": "off",
31+
"import/no-extraneous-dependencies": "off"
32+
}
33+
}
34+
],
35+
"ignorePatterns": [
36+
"dist",
37+
"node_modules",
38+
"gen"
39+
]
40+
}

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,32 @@ jobs:
2424
- run: yarn test
2525
env:
2626
CI: true
27+
eslint:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Setup Node
32+
uses: actions/setup-node@v2
33+
with:
34+
node-version: 17
35+
- name: Cache Yarn
36+
uses: actions/cache@v2
37+
with:
38+
path: '**/node_modules'
39+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-yarn-
42+
- run: yarn install --frozen-lockfile
43+
- run: yarn lint-fix
44+
- name: Auto commit fixed code
45+
id: auto-commit-action
46+
uses: stefanzweifel/git-auto-commit-action@v4
47+
with:
48+
commit_message: Apply auto lint-fix changes
49+
branch: ${{ github.head_ref }}
50+
- name: eslint
51+
if: steps.auto-commit-action.outputs.changes_detected == 'false'
52+
uses: reviewdog/action-eslint@v1
53+
with:
54+
level: warning
55+
reporter: github-pr-review

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"build": "run-p build:*",
2424
"build:main": "tsc -p tsconfig.main.json",
2525
"build:module": "tsc -p tsconfig.module.json",
26+
"lint": "eslint --ext .ts .",
27+
"lint-fix": "eslint --fix --ext .ts .",
2628
"generate": "run-p build:* && graphql-codegen",
2729
"prepublish": "run-p build:*"
2830
},
@@ -47,6 +49,9 @@
4749
"@graphql-codegen/typescript": "^2.4.2",
4850
"@tsconfig/recommended": "^1.0.1",
4951
"@types/jest": "^27.4.0",
52+
"@typescript-eslint/eslint-plugin": "^5.10.0",
53+
"@typescript-eslint/parser": "^5.10.0",
54+
"eslint": "^8.7.0",
5055
"jest": "^27.4.7",
5156
"npm-run-all": "^4.1.5",
5257
"ts-jest": "^27.1.3",

src/config.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,3 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
115115
*/
116116
directives?: DirectiveConfig;
117117
}
118-
119-
interface YupSchemaPluginConfig {
120-
/**
121-
* @description Generates yup schema as strict.
122-
* @default false
123-
* @see https://github.com/jquense/yup#schemastrictenabled-boolean--false-schema
124-
*
125-
* @exampleMarkdown
126-
* ```yml
127-
* generates:
128-
* path/to/file.ts:
129-
* plugins:
130-
* - graphql-codegen-validation-schema
131-
* config:
132-
* yup:
133-
* strict: true
134-
* ```
135-
*/
136-
strict?: boolean;
137-
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const plugin: PluginFunction<
2323
leave: visitor,
2424
});
2525

26+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2627
// @ts-ignore
2728
const generated = result.definitions.filter((def) => typeof def === "string");
2829

tests/regexp.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ describe("isConvertableRegexp", () => {
1414
"/hello/y",
1515
"/hello/dgimsuy",
1616
`/\\w+\\s/g`,
17+
// eslint-disable-next-line no-useless-escape
1718
`/^[a-z]+:[\\\/]$/i`,
19+
// eslint-disable-next-line no-useless-escape
1820
`/^(?:\d{3}|\(\d{3}\))([-\/\.])\d{3}\\1\d{4}$/`,
1921
])("%s", (maybeRegexp) => {
2022
expect(isConvertableRegexp(maybeRegexp)).toBeTruthy();

0 commit comments

Comments
 (0)