Skip to content

Commit

Permalink
fix: scopeName not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 21, 2021
1 parent ff1fe86 commit 45ed16d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions lib/grammars/coffeescript.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
"use babel"

/*
* decaffeinate suggestions:
* DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
let GrammarUtils
import path from "path"
const { command } = (GrammarUtils = require("../grammar-utils"))
Expand All @@ -24,8 +18,9 @@ export const CoffeeScript = {
"Selection Based": {
command,
args(context) {
const { scopeName } = __guard__(atom.workspace.getActiveTextEditor(), (x) => x.getGrammar())
const lit = (scopeName != null ? scopeName.includes("lit") : undefined) ? "lit" : ""
const editor = atom.workspace.getActiveTextEditor()
const scopeName = editor ? editor.getGrammar().scopeName : null
const lit = scopeName !== null && scopeName.includes("lit") ? "lit" : ""
const code = context.getCode()
const filepath = GrammarUtils.createTempFileWithCode(code, `.${lit}coffee`)
return args({ filepath })
Expand All @@ -51,7 +46,3 @@ export const IcedCoffeeScript = {
},
},
}

function __guard__(value, transform) {
return typeof value !== "undefined" && value !== null ? transform(value) : undefined
}

0 comments on commit 45ed16d

Please sign in to comment.