Skip to content

add eslint #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"env": {
"node": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
},
"overrides": [
{
"files": [
"*.spec.ts"
],
"env": {
"jest": true
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"import/no-extraneous-dependencies": "off"
}
}
],
"ignorePatterns": [
"dist",
"node_modules",
"gen"
]
}
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,32 @@ jobs:
- run: yarn test
env:
CI: true
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 17
- name: Cache Yarn
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --frozen-lockfile
- run: yarn lint-fix
- name: Auto commit fixed code
id: auto-commit-action
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply auto lint-fix changes
branch: ${{ github.head_ref }}
- name: eslint
if: steps.auto-commit-action.outputs.changes_detected == 'false'
uses: reviewdog/action-eslint@v1
with:
level: warning
reporter: github-pr-review
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"build": "run-p build:*",
"build:main": "tsc -p tsconfig.main.json",
"build:module": "tsc -p tsconfig.module.json",
"lint": "eslint --ext .ts .",
"lint-fix": "eslint --fix --ext .ts .",
"generate": "run-p build:* && graphql-codegen",
"prepublish": "run-p build:*"
},
Expand All @@ -47,6 +49,9 @@
"@graphql-codegen/typescript": "^2.4.2",
"@tsconfig/recommended": "^1.0.1",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"eslint": "^8.7.0",
"jest": "^27.4.7",
"npm-run-all": "^4.1.5",
"ts-jest": "^27.1.3",
Expand Down
20 changes: 0 additions & 20 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,3 @@ export interface ValidationSchemaPluginConfig extends TypeScriptPluginConfig {
*/
directives?: DirectiveConfig;
}

interface YupSchemaPluginConfig {
/**
* @description Generates yup schema as strict.
* @default false
* @see https://github.com/jquense/yup#schemastrictenabled-boolean--false-schema
*
* @exampleMarkdown
* ```yml
* generates:
* path/to/file.ts:
* plugins:
* - graphql-codegen-validation-schema
* config:
* yup:
* strict: true
* ```
*/
strict?: boolean;
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const plugin: PluginFunction<
leave: visitor,
});

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

Expand Down
2 changes: 2 additions & 0 deletions tests/regexp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ describe("isConvertableRegexp", () => {
"/hello/y",
"/hello/dgimsuy",
`/\\w+\\s/g`,
// eslint-disable-next-line no-useless-escape
`/^[a-z]+:[\\\/]$/i`,
// eslint-disable-next-line no-useless-escape
`/^(?:\d{3}|\(\d{3}\))([-\/\.])\d{3}\\1\d{4}$/`,
])("%s", (maybeRegexp) => {
expect(isConvertableRegexp(maybeRegexp)).toBeTruthy();
Expand Down
Loading