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

package: adopt prettier-standard style #310

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"env": {
"jasmine": true
},
"globals": {
"waitsForPromise": true,
"atom": true
},
"rules": {
"no-template-curly-in-string": "off"
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
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
37 changes: 0 additions & 37 deletions coffeelint.json

This file was deleted.

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
Loading