Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
fix: remove loading workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 24, 2021
1 parent 2acfa43 commit 23f20af
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@
"test": "npm run babel && atom --test spec",
"clean": "shx rm -rf dist",
"babel": "cross-env NODE_ENV=development cross-env BABEL_KEEP_MODULES=false babel src --out-dir dist --delete-dir-on-start",
"dev": "npm run clean && cross-env NODE_ENV=development cross-env BABEL_KEEP_MODULES=true rollup -c -w",
"build": "npm run clean && cross-env NODE_ENV=production cross-env BABEL_KEEP_MODULES=true rollup -c ",
"dev": "npm run babel && cross-env NODE_ENV=development cross-env BABEL_KEEP_MODULES=true rollup -c -w",
"build": "npm run babel && cross-env NODE_ENV=production cross-env BABEL_KEEP_MODULES=true rollup -c ",
"prepare": "npm run build"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion spec/migrate-config-options-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use babel'

import migrateConfigOptions from '../dist/migrate-config-options'
import { migrateConfigOptions } from '../dist/migrate-config-options'
import makeSpy from './make-spy'

describe('migrateConfigOptions()', () => {
Expand Down
24 changes: 2 additions & 22 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
// eslint-disable-next-line import/no-extraneous-dependencies, import/extensions
import { CompositeDisposable } from 'atom'
import { hasValidScope } from './validate/editor'
import * as helpers from './helpers'
import { migrateConfigOptions } from './migrate-config-options'

// Internal variables
const idleCallbacks = new Set()

// Dependencies
// NOTE: We are not directly requiring these in order to reduce the time it
// takes to require this file as that causes delays in Atom loading this package
let helpers
let migrateConfigOptions

const loadDeps = () => {
if (!helpers) {
helpers = require('./helpers')
}
}

const makeIdleCallback = (work) => {
let callbackId
const callBack = () => {
Expand All @@ -31,15 +21,12 @@ const scheduleIdleTasks = () => {
const linterEslintInstallPeerPackages = () => {
require('atom-package-deps').install('linter-eslint')
}
const linterEslintLoadDependencies = loadDeps
const linterEslintStartWorker = () => {
loadDeps()
helpers.startWorker()
}

if (!atom.inSpecMode()) {
makeIdleCallback(linterEslintInstallPeerPackages)
makeIdleCallback(linterEslintLoadDependencies)
makeIdleCallback(linterEslintStartWorker)
}
}
Expand Down Expand Up @@ -71,9 +58,6 @@ module.exports = {
activate() {
this.subscriptions = new CompositeDisposable()

if (!migrateConfigOptions) {
migrateConfigOptions = require('./migrate-config-options')
}
migrateConfigOptions()

const embeddedScope = 'source.js.embedded.html'
Expand Down Expand Up @@ -115,7 +99,6 @@ module.exports = {

this.subscriptions.add(atom.commands.add('atom-text-editor', {
'linter-eslint:debug': async () => {
loadDeps()
const debugString = await helpers.generateDebugString()
const notificationOptions = { detail: debugString, dismissable: true }
atom.notifications.addInfo('linter-eslint debugging information', notificationOptions)
Expand Down Expand Up @@ -203,7 +186,6 @@ module.exports = {
return null
}

loadDeps()

if (filePath.includes('://')) {
// If the path is a URL (Nuclide remote file) return a message
Expand Down Expand Up @@ -262,8 +244,6 @@ module.exports = {
return
}

loadDeps()

if (textEditor.isModified()) {
// Abort for invalid or unsaved text editors
const message = 'Linter-ESLint: Please save before fixing'
Expand Down
2 changes: 1 addition & 1 deletion src/migrate-config-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ function migrateConfigOptions(migrations = activeMigrations) {
}
}

module.exports = migrateConfigOptions
exports.migrateConfigOptions = migrateConfigOptions

0 comments on commit 23f20af

Please sign in to comment.