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

chore(eslint): upgrade eslint #15457

Merged
merged 18 commits into from
Oct 18, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
119 changes: 63 additions & 56 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,69 @@
module.exports = {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": __dirname,
"ecmaFeatures": {
"jsx": true
}
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.test.json',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 sorry

tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
"plugins": [
"@typescript-eslint",
"react",
"prettier"
],
"env": {
"browser": true,
"es6": true,
"jest": true
plugins: ['@typescript-eslint', 'react', 'prettier'],
env: {
browser: true,
es6: true,
jest: true,
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/react",
"prettier/@typescript-eslint"
extends: [
'plugin:react/recommended',
'plugin:prettier/recommended',
'prettier/react',
'prettier/@typescript-eslint',
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
"settings": {
"react": {
"version": "detect"
}
settings: {
react: {
version: 'detect',
},
},
rules: {
'no-console': ['error', {allow: ['warn', 'error']}],
'no-empty': 'off',
'getter-return': 'off',
'no-extra-boolean-cast': 'off',
'no-case-declarations': 'off',
'no-useless-escape': 'off',
'no-undef': 'off',
'no-fallthrough': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{varsIgnorePattern: '^_', argsIgnorePattern: '^_'},
],
'react/jsx-no-target-blank': 'off',
'react/jsx-curly-brace-presence': [
'error',
{props: 'never', children: 'never'},
],
'react/display-name': 'off',
'react/no-unescaped-entities': 'off',
'react/prop-types': 'off',
'react/no-find-dom-node': 'off',
},
"rules": {
"no-console": ["error", {"allow": ["warn", "error"]}],
"no-empty": "off",
"getter-return": "off",
"no-extra-boolean-cast": "off",
"no-case-declarations": "off",
"no-useless-escape": "off",
"no-undef": "off",
"no-fallthrough": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-interface": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-unused-vars": ["error", {"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}],
"react/jsx-no-target-blank": "off",
"react/jsx-curly-brace-presence": ["error", {"props": "never", "children": "never" }],
"react/display-name": "off",
"react/no-unescaped-entities": "off",
"react/prop-types": "off",
"react/no-find-dom-node": "off"
}
}
10 changes: 6 additions & 4 deletions ui/cypress/e2e/buckets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ describe('Buckets', () => {

it('can delete a bucket', () => {
const bucket1 = 'newbucket1'
const bucket2 = 'newbucket2'
cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, bucket1)
cy.createBucket(id, name, bucket2)
})

cy.getByTestID(`bucket--card--name ${bucket1}`).should('exist')

cy.getByTestID(`context-delete-menu ${bucket1}`).click()
cy.getByTestID(`context-delete-bucket ${bucket1}`).click()

// normally we would assert for empty state here
// but we cannot because of the default system buckets
// since cypress selectors are so fast, that sometimes a bucket
// that is deleted will be selected before it gets deleted
cy.reload()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.


cy.getByTestID(`bucket--card--name ${bucket1}`).should('not.exist')
})
})
Expand Down
2 changes: 2 additions & 0 deletions ui/cypress/e2e/collectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ describe('Collectors', () => {
cy.createTelegraf(thirdTelegraf, description, id)
})

cy.reload()

cy.getByTestID('search-widget').type(firstTelegraf)

cy.getByTestID('resource-card').should('have.length', 1)
Expand Down
14 changes: 7 additions & 7 deletions ui/cypress/e2e/labels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ describe('labels', () => {

function hex2BgColor(hex: string): string {
hex = hex.replace('#', '')
let subvals = hex.match(/.{1,2}/g) as string[]
let red: number = parseInt(subvals[0], 16)
let green: number = parseInt(subvals[1], 16)
let blue: number = parseInt(subvals[2], 16)
const subvals = hex.match(/.{1,2}/g) as string[]
const red: number = parseInt(subvals[0], 16)
const green: number = parseInt(subvals[1], 16)
const blue: number = parseInt(subvals[2], 16)
// background-color: rgb(50, 107, 186);

return `background-color: rgb(${red}, ${green}, ${blue});`
Expand Down Expand Up @@ -317,7 +317,7 @@ describe('labels', () => {

// Check initial sort asc
cy.getByTestIDSubStr('label--pill').then(labels => {
for (var i = 0; i < labels.length; i++) {
for (let i = 0; i < labels.length; i++) {
cy.getByTestIDSubStr('label--pill')
.eq(i)
.should('have.text', names[i].name)
Expand All @@ -328,7 +328,7 @@ describe('labels', () => {

// check sort desc
cy.getByTestIDSubStr('label--pill').then(labels => {
for (var i = 0; i < labels.length; i++) {
for (let i = 0; i < labels.length; i++) {
cy.getByTestIDSubStr('label--pill')
.eq(i)
.should('have.text', names[labels.length - (i + 1)].name)
Expand All @@ -339,7 +339,7 @@ describe('labels', () => {
cy.getByTestID('sorter--name').click()

cy.getByTestIDSubStr('label--pill').then(labels => {
for (var i = 0; i < labels.length; i++) {
for (let i = 0; i < labels.length; i++) {
cy.getByTestIDSubStr('label--pill')
.eq(i)
.should('have.text', names[i].name)
Expand Down
6 changes: 3 additions & 3 deletions ui/cypress/e2e/onboarding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Onboarding', () => {
cy.wait('@orgSetup')

cy.get('@orgSetup').then(xhr => {
let orgId: string = xhr.responseBody.org.id
const orgId: string = xhr.responseBody.org.id

//wait for new page to load
cy.location('pathname').should('include', 'onboarding/2')
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('Onboarding', () => {
cy.wait('@orgSetup')

cy.get('@orgSetup').then(xhr => {
let orgId: string = xhr.responseBody.org.id
const orgId: string = xhr.responseBody.org.id

//wait for new page to load
cy.location('pathname').should('include', 'onboarding/2')
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('Onboarding', () => {
cy.wait('@orgSetup')

cy.get('@orgSetup').then(xhr => {
let orgId: string = xhr.responseBody.org.id
const orgId: string = xhr.responseBody.org.id
//wait for new page to load

cy.location('pathname').should('include', 'onboarding/2')
Expand Down
40 changes: 19 additions & 21 deletions ui/cypress/e2e/tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('tokens', () => {
},
]

//check out array.reduce for the nested calls here
// check out array.reduce for the nested calls here
cy.request('api/v2/authorizations').then(resp => {
expect(resp.body).to.exist
authData.push({
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('tokens', () => {
: 0
)

for (var i = 0; i < rows.length; i++) {
for (let i = 0; i < rows.length; i++) {
cy.getByTestID('editable-name')
.eq(i)
.children('a')
Expand All @@ -121,33 +121,32 @@ describe('tokens', () => {
})

it('can filter tokens', () => {
//basic filter
// basic filter
cy.getByTestID('input-field--filter').type('test')
cy.getByTestID('table-row').should('have.length', 3)

//clear filter
// clear filter
cy.getByTestID('input-field--filter').clear()
cy.getByTestID('table-row').should('have.length', 4)

//exotic filter
// exotic filter
cy.getByTestID('input-field--filter').type('\u0950')
cy.getByTestID('table-row').should('have.length', 1)
})

it('can change token activation status', () => {
//toggle on
// toggle on
cy.getByTestID('table-row')
.contains('token test 02')
.parents('[data-testid=table-row]')
.within(() => {
cy.getByTestID('slide-toggle')
.click()
.then(() => {
//wait for backend to sync
// wait for backend to sync
cy.wait(1000)

//check for status update on backend
// @ts-ignore
// check for status update on backend
cy.request(
'api/v2/authorizations/' +
(authData.find(function(item) {
Expand All @@ -173,11 +172,10 @@ describe('tokens', () => {
cy.getByTestID('slide-toggle')
.click()
.then(() => {
//wait for backend to sync
// wait for backend to sync
cy.wait(1000)

//check for status update on backend
// @ts-ignore
// check for status update on backend
cy.request(
'api/v2/authorizations/' +
(authData.find(function(item) {
Expand Down Expand Up @@ -222,7 +220,7 @@ describe('tokens', () => {
it('can generate a read/write token', () => {
cy.getByTestID('table-row').should('have.length', 4)

//create some extra buckets for filters
// create some extra buckets for filters
cy.get<Organization>('@org').then(({id, name}) => {
cy.createBucket(id, name, 'Magna Carta').then(() => {
cy.createBucket(id, name, 'Sicilsky Bull').then(() => {
Expand All @@ -236,7 +234,7 @@ describe('tokens', () => {
cy.getByTestID('dropdown-item generate-token--read-write').click()
cy.getByTestID('overlay--container').should('be.visible')

//check cancel
// check cancel
cy.getByTestID('button--cancel').click()
cy.getByTestID('overlay--container').should('not.be.visible')
cy.getByTestID('table-row').should('have.length', 4)
Expand All @@ -247,7 +245,7 @@ describe('tokens', () => {
cy.getByTestID('dropdown-item generate-token--read-write').click()
cy.getByTestID('overlay--container').should('be.visible')

//Create a token //todo filters in this or seperate test
// Create a token //todo filters in this or seperate test
cy.getByTestID('input-field--descr').type('Jeton 01')
cy.getByTestID('builder-card--body')
.eq(0)
Expand All @@ -263,7 +261,7 @@ describe('tokens', () => {

cy.getByTestID('button--save').click()

//Verify token
// Verify token
cy.getByTestID('table-row')
.should('have.length', 5)
.contains('Jeton 01')
Expand Down Expand Up @@ -312,11 +310,11 @@ describe('tokens', () => {
.contains('token test \u0950')
.click()

//title match
// title match
cy.getByTestID('overlay--container').should('be.visible')
cy.getByTestID('overlay--header').should('contain', 'token test \u0950')

//summary match
// summary match
cy.getByTestID('permissions-section').should('have.length', 4)
cy.getByTestID('permissions-section')
.contains('views')
Expand All @@ -331,14 +329,14 @@ describe('tokens', () => {
.contains('buckets')
.should('be.visible')

//copy to clipboard + notification
// copy to clipboard + notification
cy.getByTestID('button-copy').click()
cy.getByTestID('notification-success').should($msg => {
expect($msg).to.contain('has been copied to clipboard')
})
//todo check system clipboard
// todo check system clipboard

//close button
// close button
cy.getByTestID('overlay--header').within(() => {
cy.get('button').click()
})
Expand Down