Skip to content

Commit

Permalink
Add linting to CI/CD (#16)
Browse files Browse the repository at this point in the history
* Add eslint and fix linting errors

* update README.md and add updated package-lock

* ci: make lint & format scripts tech agnostic

* ci: fix typo in README.md

* doc: fix typos
  • Loading branch information
jhowlett-scottlogic authored Oct 10, 2022
1 parent a3615cb commit 65b47ab
Show file tree
Hide file tree
Showing 8 changed files with 3,790 additions and 108 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
example
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
env: {
node: true
},
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"parserOptions": {
ecmaVersion: "latest",
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off"
}
};
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
run-eslint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install Node.js dependencies
run: npm ci

- name: Code Linting Check
run: npm run lint:check
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ The second script requires values for the featurePath & generatePath:
npm test {featurePath} {generatorPath}
~~~
## Linting
Two scripts are available to help you find linting errors:
~~~
npm run eslint:check
~~~
This runs eslint in check mode which will raise errors found but not try and fix them.
This is also ran on a PR and a push to main. It will fail if any errors were found.
~~~
npm run eslint:write
~~~
This runs eslint in write mode which will raise errors found and try to fix them.
## Notes
The openapi-forge dependency is pointing to commit:0fb044b3a2808e8faf82786f168a12763f5aaeca. If openapi-forge is updated and openapi-forge-typescript requires this updated version then the commit reference in package.json will have to be updated. This is a temporary measure and will be fixed once the packages are properly versioned and hosted on npm.
4 changes: 2 additions & 2 deletions features/support/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ModelSteps extends BaseModelStep {
private serverResponseObject: any;
private api: any;

createApi(serverIndex: number = 0): any {
createApi(serverIndex = 0): any {
const apiModule = require("../api/api.ts");
const configurationModule = require("../api/configuration.ts");

Expand Down Expand Up @@ -69,7 +69,7 @@ export class ModelSteps extends BaseModelStep {
console.error(`Method ${methodName} not found`);
}
values = values.map((value) => (isJson(value) ? JSON.parse(value) : value));
await this.api[methodName].apply(this.api, values);
await this.api[methodName](...values);
}

@when(/calling the method ([a-zA-Z]*) with array "(.*)"/)
Expand Down
Loading

0 comments on commit 65b47ab

Please sign in to comment.