Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
package: run prettier-standard --lint and fix errors
Browse files Browse the repository at this point in the history
Almost all of these changes were made automatically

List of errors that had to be resolved manually:

(`no-template-curly-in-string` errors were resolved by turning the rule off)
.../snippets/lib/snippets.js
  156:31  error  Expected error to be handled                      handle-callback-err
  164:9   error  Unexpected literal in error position of callback  standard/no-callback-literal
  171:31  error  Expected error to be handled                      handle-callback-err
  286:7   error  Expected error to be handled                      handle-callback-err
  358:11  error  Expected error to be handled                      handle-callback-err
  372:14  error  Unexpected literal in error position of callback  standard/no-callback-literal

.../snippets/spec/body-parser-spec.js
   26:7   error  Unexpected template string expression  no-template-curly-in-string
   54:39  error  Unexpected template string expression  no-template-curly-in-string
   65:39  error  Unexpected template string expression  no-template-curly-in-string

   79:7   error  Unexpected template string expression  no-template-curly-in-string
  111:39  error  Unexpected template string expression  no-template-curly-in-string
  129:39  error  Unexpected template string expression  no-template-curly-in-string
  151:39  error  Unexpected template string expression  no-template-curly-in-string
  171:39  error  Unexpected template string expression  no-template-curly-in-string
  189:39  error  Unexpected template string expression  no-template-curly-in-string

.../snippets/spec/snippets-spec.js
    75:41  error  Unexpected template string expression  no-template-curly-in-string
   199:19  error  Unexpected template string expression  no-template-curly-in-string
   257:19  error  Unexpected template string expression  no-template-curly-in-string
   271:19  error  Unexpected template string expression  no-template-curly-in-string
   276:19  error  Unexpected template string expression  no-template-curly-in-string
   280:19  error  Unexpected template string expression  no-template-curly-in-string
   285:15  error  Unexpected template string expression  no-template-curly-in-string
   289:19  error  Unexpected template string expression  no-template-curly-in-string
   293:19  error  Unexpected template string expression  no-template-curly-in-string
   297:19  error  Unexpected template string expression  no-template-curly-in-string
   301:19  error  Unexpected template string expression  no-template-curly-in-string
  1335:23  error  Unexpected template string expression  no-template-curly-in-string
  1355:19  error  Unexpected template string expression  no-template-curly-in-string
  1360:19  error  Unexpected template string expression  no-template-curly-in-string
  1385:14  error  Unexpected template string expression  no-template-curly-in-string
  1397:14  error  Unexpected template string expression  no-template-curly-in-string
  • Loading branch information
fluvf committed Sep 26, 2020
1 parent e8024c8 commit 4e658b3
Show file tree
Hide file tree
Showing 20 changed files with 2,138 additions and 1,617 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"globals": {
"waitsForPromise": true,
"atom": true
},
"rules": {
"no-template-curly-in-string": "off"
}
}
12 changes: 6 additions & 6 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Do you want to ask a question? Are you looking for support? The Atom message boa

### Prerequisites

* [ ] Put an X between the brackets on this line if you have done all of the following:
* Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
* Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
* Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
* Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
* Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
- [ ] Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages

### Description

Expand Down
4 changes: 2 additions & 2 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Requirements

* Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
* All new code requires tests to ensure against regressions
- Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
- All new code requires tests to ensure against regressions

### Description of the Change

Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Snippets package

[![macOS Build Status](https://travis-ci.org/atom/snippets.svg?branch=master)](https://travis-ci.org/atom/snippets) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/8hlc0onofkgbxw53/branch/master?svg=true)](https://ci.appveyor.com/project/Atom/snippets/branch/master) [![Dependency Status](https://david-dm.org/atom/snippets.svg)](https://david-dm.org/atom/snippets)

Expand snippets matching the current prefix with <kbd>tab</kbd> in Atom.
Expand Down Expand Up @@ -27,23 +28,25 @@ Under each snippet name is a `prefix` that should trigger the snippet and a `bod
The above example adds a `log` snippet to JavaScript files that would expand to.

```js
console.log("crash");
console.log('crash')
```

The string `"crash"` would be initially selected and pressing tab again would place the cursor after the `;`

### Optional parameters

These parameters are meant to provide extra information about your snippet to [autocomplete-plus](https://github.com/atom/autocomplete-plus/wiki/Provider-API).

* `leftLabel` will add text to the left part of the autocomplete results box.
* `leftLabelHTML` will overwrite what's in `leftLabel` and allow you to use a bit of CSS such as `color`.
* `rightLabelHTML`. By default, in the right part of the results box you will see the name of the snippet. When using `rightLabelHTML` the name of the snippet will no longer be displayed, and you will be able to use a bit of CSS.
* `description` will add text to a description box under the autocomplete results list.
* `descriptionMoreURL` URL to the documentation of the snippet.
- `leftLabel` will add text to the left part of the autocomplete results box.
- `leftLabelHTML` will overwrite what's in `leftLabel` and allow you to use a bit of CSS such as `color`.
- `rightLabelHTML`. By default, in the right part of the results box you will see the name of the snippet. When using `rightLabelHTML` the name of the snippet will no longer be displayed, and you will be able to use a bit of CSS.
- `description` will add text to a description box under the autocomplete results list.
- `descriptionMoreURL` URL to the documentation of the snippet.

![autocomplete-description](http://i.imgur.com/cvI2lOq.png)

Example:

```coffee
'.source.js':
'console.log':
Expand All @@ -55,7 +58,7 @@ Example:

### Determining the correct scope for a snippet

The outmost key of a snippet is the "scope" that you want the descendent snippets to be available in. The key should be prefixed with a period (`text.html.basic` => `.text.html.basic`). You can find out the correct scope by opening the Settings (<kbd>cmd-,</kbd> on macOS) and selecting the corresponding *Language [xxx]* package, e.g. for *Language Html*:
The outmost key of a snippet is the "scope" that you want the descendent snippets to be available in. The key should be prefixed with a period (`text.html.basic` => `.text.html.basic`). You can find out the correct scope by opening the Settings (<kbd>cmd-,</kbd> on macOS) and selecting the corresponding _Language [xxx]_ package, e.g. for _Language Html_:

![Screenshot of Language Html settings](https://cloud.githubusercontent.com/assets/1038121/5137632/126beb66-70f2-11e4-839b-bc7e84103f67.png)

Expand All @@ -68,9 +71,9 @@ This package supports a subset of the features of TextMate snippets, [documented

The following features are not yet supported:

* Variables
* Interpolated shell code
* Conditional insertions in transformations
- Variables
- Interpolated shell code
- Conditional insertions in transformations

### Multi-line Snippet Body

Expand Down
10 changes: 5 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: "{build}"
version: '{build}'

platform: x64

branches:
only:
- master
only:
- master

clone_depth: 10

Expand All @@ -14,8 +14,8 @@ environment:
APM_TEST_PACKAGES:

matrix:
- ATOM_CHANNEL: stable
- ATOM_CHANNEL: beta
- ATOM_CHANNEL: stable
- ATOM_CHANNEL: beta

install:
- ps: Install-Product node 4
Expand Down
17 changes: 13 additions & 4 deletions lib/editor-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,32 @@ class EditorStore {
this.existingHistoryProvider = this.buffer.historyProvider
}

const newProvider = SnippetHistoryProvider(this.existingHistoryProvider, delegates)
const newProvider = SnippetHistoryProvider(
this.existingHistoryProvider,
delegates
)
this.buffer.setHistoryProvider(newProvider)
}

stopObservingHistory (editor) {
if (this.existingHistoryProvider == null) { return }
if (this.existingHistoryProvider == null) {
return
}
this.buffer.setHistoryProvider(this.existingHistoryProvider)
this.existingHistoryProvider = null
}

observe (callback) {
if (this.observer != null) { this.observer.dispose() }
if (this.observer != null) {
this.observer.dispose()
}
this.observer = this.buffer.onDidChangeText(callback)
}

stopObserving () {
if (this.observer == null) { return false }
if (this.observer == null) {
return false
}
this.observer.dispose()
this.observer = null
return true
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import path from 'path'

export function getPackageRoot() {
const {resourcePath} = atom.getLoadSettings()
export function getPackageRoot () {
const { resourcePath } = atom.getLoadSettings()
const currentFileWasRequiredFromSnapshot = !path.isAbsolute(__dirname)
if (currentFileWasRequiredFromSnapshot) {
return path.join(resourcePath, 'node_modules', 'snippets')
Expand Down
22 changes: 12 additions & 10 deletions lib/insertion.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const ESCAPES = {
u: (flags) => {
u: flags => {
flags.lowercaseNext = false
flags.uppercaseNext = true
},
l: (flags) => {
l: flags => {
flags.uppercaseNext = false
flags.lowercaseNext = true
},
U: (flags) => {
U: flags => {
flags.lowercaseAll = false
flags.uppercaseAll = true
},
L: (flags) => {
L: flags => {
flags.uppercaseAll = false
flags.lowercaseAll = true
},
E: (flags) => {
E: flags => {
flags.uppercaseAll = false
flags.lowercaseAll = false
},
Expand Down Expand Up @@ -62,21 +62,21 @@ class Insertion {

makeReplacer (replace) {
return function replacer (...match) {
let flags = {
const flags = {
uppercaseAll: false,
lowercaseAll: false,
uppercaseNext: false,
lowercaseNext: false
}
replace = [...replace]
let result = []
const result = []
replace.forEach(token => {
if (typeof token === 'string') {
result.push(transformText(token, flags))
} else if (token.escape) {
ESCAPES[token.escape](flags, result)
} else if (token.backreference) {
let transformed = transformText(match[token.backreference], flags)
const transformed = transformText(match[token.backreference], flags)
result.push(transformed)
}
})
Expand All @@ -85,8 +85,10 @@ class Insertion {
}

transform (input) {
let { substitution } = this
if (!substitution) { return input }
const { substitution } = this
if (!substitution) {
return input
}
return input.replace(substitution.find, this.replacer)
}
}
Expand Down
9 changes: 6 additions & 3 deletions lib/snippet-body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ let parser
try {
parser = require('./snippet-body')
} catch (error) {
const {allowUnsafeEval} = require('loophole')
const { allowUnsafeEval } = require('loophole')
const fs = require('fs-plus')
const PEG = require('pegjs')

const grammarSrc = fs.readFileSync(require.resolve('./snippet-body.pegjs'), 'utf8')
const grammarSrc = fs.readFileSync(
require.resolve('./snippet-body.pegjs'),
'utf8'
)
parser = null
allowUnsafeEval(() => parser = PEG.buildParser(grammarSrc))
allowUnsafeEval(() => (parser = PEG.buildParser(grammarSrc)))
}

module.exports = parser

0 comments on commit 4e658b3

Please sign in to comment.