Skip to content

Commit

Permalink
chore: make yarn lint:js pass (#2047)
Browse files Browse the repository at this point in the history
* chore: make yarn lint:js pass

* add lint check to CI

* fix comment

* Rename the action title

* Fix last eslint failures
  • Loading branch information
theodoreb committed Aug 29, 2022
1 parent a2dfd38 commit fe68b0f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Expand Up @@ -7,7 +7,8 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
env: {
browser: true,
es6: true
es6: true,
node: true
},
plugins: ['svelte3'],
rules: {
Expand Down
36 changes: 34 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -7,6 +7,38 @@ on:
pull_request: {}

jobs:
test-lint:
name: Run eslint
runs-on: ubuntu-latest

steps:
# Checkout the repo
- name: Checkout
uses: actions/checkout@v1

# Setup Node.js build environment
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.18.1

# Cache dependencies
- name: Cache Dependencies
uses: actions/cache@v2
id: cache
with:
path: |
**/node_modules
key: yarn-${{ hashFiles('**/package.json', 'yarn.lock') }}

# Install project dependencies
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn
# Run eslint
- name: Run eslint
run: yarn lint:js

test-unit:
name: Run Unit Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -153,7 +185,7 @@ jobs:
# Run Cypress
- name: Run Tests
run: yarn test:cy:ci:firefox

automerge:
needs: [test-unit, test-integration-chrome, test-integration-firefox]
runs-on: ubuntu-latest
Expand All @@ -163,4 +195,4 @@ jobs:
steps:
- uses: fastify/github-action-merge-dependabot@v3.2.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
github-token: ${{secrets.GITHUB_TOKEN}}
10 changes: 5 additions & 5 deletions cypress.config.js
@@ -1,4 +1,4 @@
const { defineConfig } = require('cypress')
const { defineConfig } = require('cypress');

module.exports = defineConfig({
fixturesFolder: 'test/cypress/fixtures',
Expand All @@ -9,10 +9,10 @@ module.exports = defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./test/cypress/plugins/index.js')(on, config)
return require('./test/cypress/plugins/index.js')(on, config);
},
baseUrl: 'http://localhost:9002',
specPattern: 'test/cypress/integration/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'test/cypress/support/index.js',
},
})
supportFile: 'test/cypress/support/index.js'
}
});
14 changes: 10 additions & 4 deletions src/js/utils/general.js
@@ -1,6 +1,9 @@
import { createPopper } from '@popperjs/core';
import { isFunction, isString } from './type-check';
import { makeCenteredPopper, generateFocusAfterRenderModifier } from './popper-options';
import {
makeCenteredPopper,
generateFocusAfterRenderModifier
} from './popper-options';

/**
* Ensure class prefix ends in `-`
Expand Down Expand Up @@ -56,10 +59,13 @@ export function parseAttachTo(step) {
* @returns {boolean}
*/
export function shouldCenterStep(resolvedAttachToOptions) {
if (resolvedAttachToOptions === undefined || resolvedAttachToOptions === null) {
return true
if (
resolvedAttachToOptions === undefined ||
resolvedAttachToOptions === null
) {
return true;
}

return !resolvedAttachToOptions.element || !resolvedAttachToOptions.on;
}

Expand Down
2 changes: 2 additions & 0 deletions test/unit/components/shepherd-modal.spec.js
Expand Up @@ -254,6 +254,7 @@ describe('components/ShepherdModal', () => {
showStub.restore();
});

// eslint-disable-next-line jest/no-disabled-tests
it.skip('useModalOverlay: false, hides modal', async() => {
const modalComponent = new ShepherdModal({
target: document.body,
Expand All @@ -280,6 +281,7 @@ describe('components/ShepherdModal', () => {
modalComponent.$destroy();
});

// eslint-disable-next-line jest/no-disabled-tests
it.skip('useModalOverlay: true, shows modal', async() => {
const modalComponent = new ShepherdModal({
target: document.body,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/step.spec.js
Expand Up @@ -493,7 +493,7 @@ describe('Tour | Step', () => {
step._scrollTo();

expect(resHandlerCalled).toBeTruthy();
expect(resSpy).toBeCalled();
expect(resSpy).toHaveBeenCalled();
})

it('calls the custom handler after before-show promise resolution', () => {
Expand All @@ -517,7 +517,7 @@ describe('Tour | Step', () => {
step._scrollTo();

expect(resHandlerAdded).toBeTruthy();
expect(resSpy).toBeCalled();
expect(resSpy).toHaveBeenCalled();
});
});

Expand Down
6 changes: 2 additions & 4 deletions test/unit/utils/general.spec.js
@@ -1,7 +1,5 @@
import { should } from 'chai';
import { spy } from 'sinon';
import { Step } from '../../../src/js/step.js';
import { Tour } from '../../../src/js/tour.js';
import { getPopperOptions, parseAttachTo, shouldCenterStep } from '../../../src/js/utils/general.js';

describe('General Utils', function() {
Expand Down Expand Up @@ -116,7 +114,7 @@ describe('General Utils', function() {
expect(actualModifier).toMatchObject(expectedModifier);
});
});

describe('shouldCenterStep()', () => {
it('Returns true when resolved attachTo options are falsy', () => {
const emptyObjAttachTo = {};
Expand All @@ -141,7 +139,7 @@ describe('General Utils', function() {

it('Returns true when element property is null', () => {
const elementAttachTo = { element: null}; // FAILS

expect(shouldCenterStep(elementAttachTo)).toBe(true)
})
})
Expand Down

0 comments on commit fe68b0f

Please sign in to comment.