Skip to content

Commit 9252e77

Browse files
authored
Merge pull request #5 from atom-community/eslint
2 parents 14dc2aa + 43321b8 commit 9252e77

25 files changed

+3196
-392
lines changed

.coffeelintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "eslint-config-atomic",
3+
"ignorePatterns": ["dist/", "node_modules/", "spec/fixtures/"],
4+
"rules": {
5+
// because it was not followed in the codebase previously
6+
"curly": "off",
7+
// require Eslint 7
8+
"no-loss-of-precision": "off",
9+
"no-promise-executor-return": "off",
10+
"no-unreachable-loop": "off",
11+
"no-useless-backreference": "off",
12+
"default-case-last": "off"
13+
}
14+
}

.github/workflows/ci.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: CI
22

3-
on: [push, pull_request]
4-
5-
env:
6-
CI: true
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
78

89
jobs:
910
Test:
@@ -13,11 +14,25 @@ jobs:
1314
channel: [stable, beta]
1415
runs-on: ${{ matrix.os }}
1516
steps:
16-
- uses: actions/checkout@v1
17-
- uses: UziTech/action-setup-atom@v2
18-
with:
19-
version: ${{ matrix.channel }}
20-
- name: Install dependencies
21-
run: apm install
22-
- name: Run tests
23-
run: atom --test spec
17+
- uses: actions/checkout@v1
18+
- uses: UziTech/action-setup-atom@v2
19+
with:
20+
version: ${{ matrix.channel }}
21+
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: 12
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v2
28+
with:
29+
version: 6
30+
31+
- name: Install dependencies
32+
run: apm install
33+
34+
- name: Lint
35+
run: pnpm run test.lint
36+
37+
- name: Run tests
38+
run: atom --test spec

.npmrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public-hoist-pattern[]=*
2+
package-lock=false
3+
lockfile=true
4+
prefer-frozen-lockfile=true
5+
strict-peer-dependencies=false

coffeelint.json

Lines changed: 0 additions & 37 deletions
This file was deleted.

lib/buffer-search.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Point, Range, Emitter, CompositeDisposable, TextBuffer } = require('atom');
1+
const { Point, Range, Emitter, CompositeDisposable } = require('atom');
22
const FindOptions = require('./find-options');
33
const escapeHelper = require('./escape-helper');
44
const Util = require('./project/util');
@@ -69,7 +69,7 @@ class BufferSearch {
6969
}
7070

7171
search(findPattern, otherOptions) {
72-
let options = {findPattern};
72+
const options = {findPattern};
7373
Object.assign(options, otherOptions);
7474

7575
const changedParams = this.findOptions.set(options);
@@ -137,11 +137,11 @@ class BufferSearch {
137137
}
138138

139139
createMarkers(start, end) {
140-
let newMarkers = [];
140+
const newMarkers = [];
141141
if (this.findOptions.findPattern && this.editor) {
142142
this.selectedRanges = this.editor.getSelectedBufferRanges()
143143

144-
let searchRanges = []
144+
const searchRanges = []
145145
if (this.findOptions.inCurrentSelection) {
146146
searchRanges.push(...this.selectedRanges.filter(range => !range.isEmpty()))
147147
}
@@ -180,7 +180,7 @@ class BufferSearch {
180180
let scanEnd = Point.ZERO;
181181
let markerIndex = 0;
182182

183-
for (let change of changes) {
183+
for (const change of changes) {
184184
const changeStart = change.start;
185185
const changeEnd = change.start.traverse(change.newExtent);
186186
if (changeEnd.isLessThan(scanEnd)) continue;
@@ -207,7 +207,7 @@ class BufferSearch {
207207
markerIndex++;
208208
}
209209

210-
let spliceStart, scanStart
210+
let spliceStart; let scanStart
211211
if (precedingMarkerIndex >= 0) {
212212
spliceStart = precedingMarkerIndex;
213213
scanStart = this.markers[precedingMarkerIndex].getBufferRange().start;
@@ -227,7 +227,7 @@ class BufferSearch {
227227

228228
const newMarkers = this.createMarkers(scanStart, scanEnd) || [];
229229
const oldMarkers = this.markers.splice(spliceStart, (spliceEnd - spliceStart) + 1, ...newMarkers);
230-
for (let oldMarker of oldMarkers) {
230+
for (const oldMarker of oldMarkers) {
231231
oldMarker.destroy();
232232
}
233233
markerIndex += newMarkers.length - oldMarkers.length;

lib/find-view.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const _ = require('underscore-plus');
2-
const {TextBuffer, TextEditor, CompositeDisposable} = require('atom');
2+
const {TextEditor, CompositeDisposable} = require('atom');
33
const Util = require('./project/util');
44
const etch = require('etch');
55
const $ = etch.dom;
@@ -211,7 +211,7 @@ class FindView {
211211

212212
didHide() {
213213
this.hideAllTooltips();
214-
let workspaceElement = atom.views.getView(atom.workspace);
214+
const workspaceElement = atom.views.getView(atom.workspace);
215215
workspaceElement.focus();
216216
workspaceElement.classList.remove('find-visible');
217217
}
@@ -223,7 +223,7 @@ class FindView {
223223

224224
handleEvents() {
225225
this.findEditor.onDidStopChanging(() => this.liveSearch());
226-
this.refs.nextButton.addEventListener('click', e => e.shiftKey ? this.findPrevious({focusEditorAfter: true}) : this.findNext({focusEditorAfter: true}));
226+
this.refs.nextButton.addEventListener('click', e => (e.shiftKey ? this.findPrevious({focusEditorAfter: true}) : this.findNext({focusEditorAfter: true})));
227227
this.refs.findAllButton.addEventListener('click', this.findAll.bind(this));
228228
this.subscriptions.add(atom.commands.add('atom-workspace', {
229229
'find-and-replace:find-next': () => this.findNext({focusEditorAfter: true}),
@@ -235,7 +235,7 @@ class FindView {
235235
'find-and-replace:use-selection-as-replace-pattern': this.setSelectionAsReplacePattern.bind(this)
236236
}));
237237

238-
this.refs.replaceNextButton.addEventListener('click', e => e.shiftKey ? this.replacePrevious() : this.replaceNext());
238+
this.refs.replaceNextButton.addEventListener('click', e => (e.shiftKey ? this.replacePrevious() : this.replaceNext()));
239239
this.refs.replaceAllButton.addEventListener('click', this.replaceAll.bind(this));
240240
this.subscriptions.add(atom.commands.add('atom-workspace', {
241241
'find-and-replace:replace-previous': this.replacePrevious.bind(this),
@@ -279,7 +279,7 @@ class FindView {
279279
this.element.addEventListener('focus', () => this.findEditor.element.focus());
280280
this.element.addEventListener('click', (e) => {
281281
if (e.target.tagName === 'button') {
282-
let workspaceElement = atom.views.getView(atom.workspace);
282+
const workspaceElement = atom.views.getView(atom.workspace);
283283
workspaceElement.focus();
284284
}
285285
});
@@ -325,7 +325,7 @@ class FindView {
325325
}
326326

327327
liveSearch() {
328-
let findPattern = this.findEditor.getText();
328+
const findPattern = this.findEditor.getText();
329329
if (findPattern.length === 0 || (findPattern.length >= atom.config.get('find-and-replace.liveSearchMinimumCharacters') && !this.model.patternMatchesEmptyString(findPattern))) {
330330
return this.model.search(findPattern);
331331
}
@@ -361,7 +361,7 @@ class FindView {
361361
if (fieldToFocus) {
362362
fieldToFocus.getElement().focus();
363363
} else if (focusEditorAfter) {
364-
let workspaceElement = atom.views.getView(atom.workspace);
364+
const workspaceElement = atom.views.getView(atom.workspace);
365365
workspaceElement.focus();
366366
} else {
367367
this.findEditor.getElement().focus();
@@ -387,7 +387,7 @@ class FindView {
387387
if (this.markers && this.markers.length > 0) {
388388
let currentMarker = this.model.currentResultMarker;
389389
if (!currentMarker) {
390-
let position = this[nextIndexFn]();
390+
const position = this[nextIndexFn]();
391391
if (position) {
392392
currentMarker = this.markers[position.index];
393393
}
@@ -419,8 +419,8 @@ class FindView {
419419
this.updateReplaceEnablement();
420420

421421
if (this.model.getFindOptions().findPattern) {
422-
let results = this.markers.length;
423-
let resultsStr = results ? _.pluralize(results, 'result') : 'No results';
422+
const results = this.markers.length;
423+
const resultsStr = results ? _.pluralize(results, 'result') : 'No results';
424424
this.element.classList.remove('has-results', 'has-no-results');
425425
this.element.classList.add(results ? 'has-results' : 'has-no-results');
426426
this.setInfoMessage(`${resultsStr} found for '${this.model.getFindOptions().findPattern}'`);
@@ -472,23 +472,23 @@ class FindView {
472472
}
473473

474474
selectFirstMarkerAfterCursor() {
475-
let marker = this.firstMarkerIndexAfterCursor();
475+
const marker = this.firstMarkerIndexAfterCursor();
476476
if (!marker) { return; }
477-
let {index, wrapped} = marker;
477+
const {index, wrapped} = marker;
478478
this.selectMarkerAtIndex(index, wrapped);
479479
}
480480

481481
selectFirstMarkerStartingFromCursor() {
482-
let marker = this.firstMarkerIndexAfterCursor(true);
482+
const marker = this.firstMarkerIndexAfterCursor(true);
483483
if (!marker) { return; }
484-
let {index, wrapped} = marker;
484+
const {index, wrapped} = marker;
485485
this.selectMarkerAtIndex(index, wrapped);
486486
}
487487

488488
selectFirstMarkerBeforeCursor() {
489-
let marker = this.firstMarkerIndexBeforeCursor();
489+
const marker = this.firstMarkerIndexBeforeCursor();
490490
if (!marker) { return; }
491-
let {index, wrapped} = marker;
491+
const {index, wrapped} = marker;
492492
this.selectMarkerAtIndex(index, wrapped);
493493
}
494494

@@ -541,10 +541,10 @@ class FindView {
541541

542542
selectAllMarkers() {
543543
if (!this.markers || this.markers.length === 0) return;
544-
let ranges = (Array.from(this.markers).map((marker) => marker.getBufferRange()));
545-
let scrollMarker = this.markers[this.firstMarkerIndexAfterCursor().index];
546-
let editor = this.model.getEditor();
547-
for(let range of ranges) {
544+
const ranges = (Array.from(this.markers).map((marker) => marker.getBufferRange()));
545+
const scrollMarker = this.markers[this.firstMarkerIndexAfterCursor().index];
546+
const editor = this.model.getEditor();
547+
for(const range of ranges) {
548548
editor.unfoldBufferRow(range.start.row);
549549
}
550550
editor.setSelectedBufferRanges(ranges, {flash: true});
@@ -556,9 +556,9 @@ class FindView {
556556
if (!this.markers || this.markers.length === 0) return;
557557

558558
if (marker = this.markers[markerIndex]) {
559-
let editor = this.model.getEditor();
560-
let bufferRange = marker.getBufferRange();
561-
let screenRange = marker.getScreenRange();
559+
const editor = this.model.getEditor();
560+
const bufferRange = marker.getBufferRange();
561+
const screenRange = marker.getScreenRange();
562562

563563
if (
564564
screenRange.start.row < editor.getFirstVisibleScreenRow() ||
@@ -581,7 +581,7 @@ class FindView {
581581
}
582582

583583
setSelectionAsFindPattern() {
584-
let editor = this.model.getEditor();
584+
const editor = this.model.getEditor();
585585
if (editor && editor.getSelectedText) {
586586
let findPattern = editor.getSelectedText() || editor.getWordUnderCursor();
587587
if (this.model.getFindOptions().useRegex) {
@@ -598,7 +598,7 @@ class FindView {
598598
}
599599

600600
setSelectionAsReplacePattern() {
601-
let editor = this.model.getEditor();
601+
const editor = this.model.getEditor();
602602
if (editor && editor.getSelectedText) {
603603
let replacePattern = editor.getSelectedText() || editor.getWordUnderCursor();
604604
if (this.model.getFindOptions().useRegex) {
@@ -678,7 +678,7 @@ class FindView {
678678
}
679679

680680
anyMarkersAreSelected() {
681-
let editor = this.model.getEditor();
681+
const editor = this.model.getEditor();
682682
if (editor) {
683683
return editor.getSelectedBufferRanges().some(selectedRange => {
684684
return this.model.findMarker(selectedRange);
@@ -703,7 +703,7 @@ class FindView {
703703
toggleSelectionOption() {
704704
this.search({inCurrentSelection: !this.model.getFindOptions().inCurrentSelection});
705705

706-
let editor = this.model.getEditor();
706+
const editor = this.model.getEditor();
707707
if (editor && editor.getSelectedBufferRanges().every(range => range.isEmpty())) {
708708
this.selectFirstMarkerAfterCursor();
709709
}
@@ -717,9 +717,9 @@ class FindView {
717717
}
718718

719719
updateFindEnablement() {
720-
let editor = this.model.getEditor();
721-
let isDisabled = this.refs.findAllButton.classList.contains('disabled');
722-
let hadFindTooltip = !!this.findTooltipSubscriptions;
720+
const editor = this.model.getEditor();
721+
const isDisabled = this.refs.findAllButton.classList.contains('disabled');
722+
const hadFindTooltip = Boolean(this.findTooltipSubscriptions);
723723

724724
if (hadFindTooltip) this.findTooltipSubscriptions.dispose();
725725
this.findTooltipSubscriptions = new CompositeDisposable;
@@ -752,7 +752,7 @@ class FindView {
752752
}
753753

754754
updateReplaceEnablement() {
755-
let canReplace = this.markers && this.markers.length > 0;
755+
const canReplace = this.markers && this.markers.length > 0;
756756
if (canReplace && !this.refs.replaceAllButton.classList.contains('disabled')) return;
757757

758758
if (this.replaceTooltipSubscriptions) this.replaceTooltipSubscriptions.dispose();
@@ -791,10 +791,10 @@ class FindView {
791791

792792
showWrapIcon(icon) {
793793
if (!atom.config.get('find-and-replace.showSearchWrapIcon')) return;
794-
let editor = this.model.getEditor();
794+
const editor = this.model.getEditor();
795795
if (!editor) return;
796796

797-
let editorView = atom.views.getView(editor);
797+
const editorView = atom.views.getView(editor);
798798
if (!editorView.parentNode) return;
799799
editorView.parentNode.appendChild(this.wrapIcon);
800800

lib/find.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BufferSearch = require './buffer-search'
77
getIconServices = require './get-icon-services'
88
FindView = require './find-view'
99
ProjectFindView = require './project-find-view'
10-
ResultsModel = require './project/results-model'
10+
{ResultsModel} = require './project/results-model'
1111
ResultsPaneView = require './project/results-pane'
1212
ReporterProxy = require './reporter-proxy'
1313

0 commit comments

Comments
 (0)