Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Setup editor integrations and clean up linting
  • Loading branch information
Philip Harrison committed Jul 21, 2021
1 parent 42364b8 commit 904dc1f
Show file tree
Hide file tree
Showing 13 changed files with 1,114 additions and 395 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
trim_trailing_whitespace = true
charset = utf-8
insert_final_newline = true

[*.json, *.ts]
indent_size = 2
indent_style = space

[*.md]
trim_trailing_whitespace = false
indent_size = 2
10 changes: 4 additions & 6 deletions .eslintrc.json
@@ -1,23 +1,23 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"extends": ["plugin:github/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
"project": "./tsconfig.eslint.json"
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"camelcase": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
Expand All @@ -41,8 +41,6 @@
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/no-shadow": "error",
Expand All @@ -53,4 +51,4 @@
"es6": true,
"jest/globals": true
}
}
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install lint-staged
8 changes: 8 additions & 0 deletions .vscode/extensions.json
@@ -0,0 +1,8 @@
{
"recommendations": [
"EditorConfig.editorconfig",
"Orta.vscode-jest",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,16 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": ["javascript", "typescript"],
"eslint.alwaysShowStatus": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"editor.formatOnType": false
}
13 changes: 1 addition & 12 deletions __tests__/main.test.ts
@@ -1,13 +1,2 @@
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
const np = process.execPath
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecFileSyncOptions = {
env: process.env
}
console.log(cp.execFileSync(np, [ip], options).toString())
})
test('test runs', () => {})
36 changes: 23 additions & 13 deletions __tests__/updater-integration.test.ts
Expand Up @@ -22,27 +22,37 @@ describe('Updater', () => {
if (!containers) return

containers.forEach(function (containerInfo) {
if (containerInfo.Image.includes('docker.pkg.github.com/dependabot/dependabot-updater')) {
console.log('removing');
if (
containerInfo.Image.includes(
'docker.pkg.github.com/dependabot/dependabot-updater'
)
) {
console.log('removing')

docker.getContainer(containerInfo.Id).remove();
docker.getContainer(containerInfo.Id).remove()
}
});
});
});
})
})
})

jest.setTimeout(20000)
it('should fetch manifests', async () => {
mockDependabotAPI.getJobDetails.mockImplementation(() => {
return JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures/job-details/npm.json")).toString()).data.attributes
return JSON.parse(
fs
.readFileSync(path.join(__dirname, 'fixtures/job-details/npm.json'))
.toString()
).data.attributes
})
mockDependabotAPI.getCredentials.mockImplementation(() => {
return [{
type: "git_source",
host: "github.com",
username: "x-access-token",
password: process.env.GITHUB_TOKEN,
}]
return [
{
type: 'git_source',
host: 'github.com',
username: 'x-access-token',
password: process.env.GITHUB_TOKEN
}
]
})

await updater.pullImage()
Expand Down

0 comments on commit 904dc1f

Please sign in to comment.