Skip to content
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

Upgrade to ESLint and fix new lint errors #343

Merged
merged 2 commits into from
Oct 12, 2023
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
25 changes: 25 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-env node */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
rules: {
// Only disabling this because this code is very old but also battle-tested,
// and coming up with clever typings may break for consumers.
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['**/__tests__/*.test.ts'],
rules: {
// Unused vars are used for dependency resolution.
'@typescript-eslint/no-unused-vars': 'off',
},
},
],
}
20 changes: 12 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Name of the pipeline
name: CI

# When pushing to any branch
on: [push, pull_request]
# When pushing to `master` or when there is a PR for the branch.
on:
pull_request:
push:
branches:
- 'master'

jobs:
ci:
Expand All @@ -15,6 +19,7 @@ jobs:
- 14
- 16
- 18
- 20
- current
steps:
- name: Checkout
Expand All @@ -32,17 +37,16 @@ jobs:
- name: Build
run: npm run build

- name: Lint
- if: ${{ matrix.version == 'current' }}
name: Lint
run: npm run lint

- name: Test
run: npm run cover

- name: Coveralls
uses: coverallsapp/[email protected]
if: ${{ matrix.version == 'current' }}
with:
github-token: ${{ secrets.github_token }}
- if: ${{ matrix.version == 'current' }}
name: Coveralls
uses: coverallsapp/github-action@v2

# Cancel running workflows for the same branch when a new one is started.
concurrency:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v9.0.0

* Upgrade packages
* Fix `aliasTo` to allow passing `symbol` ([#342](https://github.com/jeffijoe/awilix/pull/342) by [@zb-sj](https://github.com/zb-sj))
* Migrate from TSLint to ESLint
* **BREAKING CHANGE**: Drop Node 12 support for real this time (updated the `engines` field)

# v8.0.1

* Upgrade packages
Expand Down
2 changes: 1 addition & 1 deletion examples/koa/repositories/messageRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function makeMessageRepository({ DB_CONNECTION_STRING }) {
// Imagine using the connection string for something useful..
console.log(
'Message repository constructed with connection string',
DB_CONNECTION_STRING
DB_CONNECTION_STRING,
)

function findMessagesForUser(userId) {
Expand Down
6 changes: 3 additions & 3 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ container.loadModules(
'services/*.js',
'repositories/*.js',
],
opts
opts,
)

// 2 ways to resolve the same service.
Expand All @@ -28,14 +28,14 @@ const classicalService = container.resolve('classicalService')

console.log(
'Resolved to the same type:',
classicalService.constructor === classicalServiceFromCradle.constructor
classicalService.constructor === classicalServiceFromCradle.constructor,
)

// This will return false because the default is to return a new instance
// when resolving.
console.log(
'Resolved to the same instance:',
classicalService === classicalServiceFromCradle
classicalService === classicalServiceFromCradle,
)

// Let's do something!
Expand Down
4 changes: 2 additions & 2 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ container.register({
})

// Resolve a dependency using the cradle.
let dep1 = container.cradle.depService
const dep1 = container.cradle.depService
// Resolve a dependency using `resolve`
let dep2 = container.resolve<DependentService>('depService')
const dep2 = container.resolve<DependentService>('depService')

// Test that all is well, should produce 'Hello world!'
console.log(dep1.getInnerData())
Expand Down
Loading