-
Notifications
You must be signed in to change notification settings - Fork 189
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
Configure ESLint for Satellite and fix ESlint errors #3151
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,7 @@ packages: | |
- 'src/web' | ||
# microservices | ||
- 'src/api/*' | ||
# satellite | ||
- 'src/satellite' | ||
# autodeployment | ||
- 'tools/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
commonjs: true, | ||
es2021: true, | ||
jest: true, | ||
}, | ||
extends: 'eslint:recommended', | ||
parserOptions: { | ||
ecmaVersion: 13, | ||
}, | ||
plugins: ['anti-trojan-source', 'jest'], | ||
rules: { | ||
/** | ||
* Halt if a trojan source attack is found | ||
* https://github.com/lirantal/eslint-plugin-anti-trojan-source | ||
*/ | ||
'anti-trojan-source/no-bidi': 'error', | ||
}, | ||
extends: '@senecacdot/eslint-config-telescope', | ||
|
||
overrides: [ | ||
{ | ||
files: ['./**/*.ts', './**/*.tsx'], | ||
env: { | ||
node: true, | ||
commonjs: true, | ||
es2021: true, | ||
jest: true, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* eslint-disable @typescript-eslint/no-shadow */ | ||
/* eslint no-unused-vars: off */ | ||
//ESLint override to prevent errors for callback vars, e.g. (req, user) => {...} | ||
// ESLint override to prevent errors for callback vars, e.g. (req, user) => {...} | ||
|
||
const nock = require('nock'); | ||
const getPort = require('get-port'); | ||
|
@@ -8,6 +9,7 @@ const jwt = require('jsonwebtoken'); | |
// Tests cause terminus to leak warning on too many listeners, increase a bit | ||
require('events').EventEmitter.defaultMaxListeners = 32; | ||
|
||
const { errors } = require('@elastic/elasticsearch'); | ||
const { | ||
Satellite, | ||
Router, | ||
|
@@ -21,7 +23,7 @@ const { | |
Elastic, | ||
fetch, | ||
} = require('./src'); | ||
const { errors } = require('@elastic/elasticsearch'); | ||
|
||
const { JWT_EXPIRES_IN, JWT_ISSUER, JWT_AUDIENCE, JWT_SECRET } = process.env; | ||
|
||
const createSatelliteInstance = (options) => { | ||
|
@@ -283,7 +285,7 @@ describe('Satellite()', () => { | |
name: 'test', | ||
}); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get('/protected', isAuthenticated(), (req, res) => { | ||
// Make sure the user payload was added to req | ||
|
@@ -336,7 +338,7 @@ describe('Satellite()', () => { | |
roles: ['user', 'admin'], | ||
}); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -355,7 +357,7 @@ describe('Satellite()', () => { | |
// Public should need no bearer token | ||
let res = await fetch(`${url}/public`); | ||
expect(res.ok).toBe(true); | ||
let body = await res.json(); | ||
const body = await res.json(); | ||
expect(body).toEqual({ hello: 'public' }); | ||
|
||
// Protected should fail without authorization header | ||
|
@@ -395,7 +397,7 @@ describe('Satellite()', () => { | |
roles: ['user', 'admin'], | ||
}); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -452,7 +454,7 @@ describe('Satellite()', () => { | |
const token = createToken({ sub: '[email protected]' }); | ||
const decoded = jwt.verify(token, JWT_SECRET); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -472,7 +474,7 @@ describe('Satellite()', () => { | |
// Public should need no bearer token | ||
let res = await fetch(`${url}/public`); | ||
expect(res.ok).toBe(true); | ||
let body = await res.json(); | ||
const body = await res.json(); | ||
expect(body).toEqual({ hello: 'public' }); | ||
|
||
// Protected should fail | ||
|
@@ -493,7 +495,7 @@ describe('Satellite()', () => { | |
}); | ||
const token = createServiceToken(); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -540,7 +542,7 @@ describe('Satellite()', () => { | |
}); | ||
const token = createToken({ sub: '[email protected]', roles: ['admin'] }); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -587,7 +589,7 @@ describe('Satellite()', () => { | |
}); | ||
const token = createToken({ sub: '[email protected]' }); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -632,7 +634,7 @@ describe('Satellite()', () => { | |
}); | ||
const token = createToken({ sub: '[email protected]' }); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -649,7 +651,7 @@ describe('Satellite()', () => { | |
// Public should need no bearer token | ||
let res = await fetch(`${url}/public`); | ||
expect(res.ok).toBe(true); | ||
let body = await res.json(); | ||
const body = await res.json(); | ||
expect(body).toEqual({ hello: 'public' }); | ||
|
||
// Protected should fail without authorization header | ||
|
@@ -676,7 +678,7 @@ describe('Satellite()', () => { | |
}); | ||
const token = createToken({ sub: '[email protected]' }); | ||
|
||
const router = service.router; | ||
const { router } = service; | ||
router.get('/public', (req, res) => res.json({ hello: 'public' })); | ||
router.get( | ||
'/protected', | ||
|
@@ -695,7 +697,7 @@ describe('Satellite()', () => { | |
// Public should need no bearer token | ||
let res = await fetch(`${url}/public`); | ||
expect(res.ok).toBe(true); | ||
let body = await res.json(); | ||
const body = await res.json(); | ||
expect(body).toEqual({ hello: 'public' }); | ||
|
||
// Protected should fail without authorization header | ||
|
@@ -977,7 +979,7 @@ describe('Redis()', () => { | |
describe('Elastic()', () => { | ||
describe('Tests for regular Elastic()', () => { | ||
test('Testing the name property which should be a string', async () => { | ||
let client = Elastic(); | ||
const client = Elastic(); | ||
|
||
const clientInfo = await client.info(); | ||
|
||
|
@@ -987,7 +989,7 @@ describe('Elastic()', () => { | |
|
||
describe('Tests for mock Elastic()', () => { | ||
const client = Elastic(); | ||
const mock = client.mock; | ||
const { mock } = client; | ||
|
||
beforeEach(() => mock.clearAll()); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we keep this plugin:
anti-trojan-source
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have it in
@senecacdot/eslint-config-telescope