Skip to content
Merged
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
1 change: 0 additions & 1 deletion .coffeelintignore

This file was deleted.

14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "eslint-config-atomic",
"ignorePatterns": ["dist/", "node_modules/", "spec/fixtures/"],
"rules": {
// because it was not followed in the codebase previously
"curly": "off",
// require Eslint 7
"no-loss-of-precision": "off",
"no-promise-executor-return": "off",
"no-unreachable-loop": "off",
"no-useless-backreference": "off",
"default-case-last": "off"
}
}
39 changes: 27 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: CI

on: [push, pull_request]

env:
CI: true
on:
pull_request:
push:
branches:
- master

jobs:
Test:
Expand All @@ -13,11 +14,25 @@ jobs:
channel: [stable, beta]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: UziTech/action-setup-atom@v2
with:
version: ${{ matrix.channel }}
- name: Install dependencies
run: apm install
- name: Run tests
run: atom --test spec
- uses: actions/checkout@v1
- uses: UziTech/action-setup-atom@v2
with:
version: ${{ matrix.channel }}

- uses: actions/setup-node@v3
with:
node-version: 12

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 6

- name: Install dependencies
run: apm install

- name: Lint
run: pnpm run test.lint

- name: Run tests
run: atom --test spec
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public-hoist-pattern[]=*
package-lock=false
lockfile=true
prefer-frozen-lockfile=true
strict-peer-dependencies=false
37 changes: 0 additions & 37 deletions coffeelint.json

This file was deleted.

14 changes: 7 additions & 7 deletions lib/buffer-search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Point, Range, Emitter, CompositeDisposable, TextBuffer } = require('atom');
const { Point, Range, Emitter, CompositeDisposable } = require('atom');
const FindOptions = require('./find-options');
const escapeHelper = require('./escape-helper');
const Util = require('./project/util');
Expand Down Expand Up @@ -69,7 +69,7 @@ class BufferSearch {
}

search(findPattern, otherOptions) {
let options = {findPattern};
const options = {findPattern};
Object.assign(options, otherOptions);

const changedParams = this.findOptions.set(options);
Expand Down Expand Up @@ -137,11 +137,11 @@ class BufferSearch {
}

createMarkers(start, end) {
let newMarkers = [];
const newMarkers = [];
if (this.findOptions.findPattern && this.editor) {
this.selectedRanges = this.editor.getSelectedBufferRanges()

let searchRanges = []
const searchRanges = []
if (this.findOptions.inCurrentSelection) {
searchRanges.push(...this.selectedRanges.filter(range => !range.isEmpty()))
}
Expand Down Expand Up @@ -180,7 +180,7 @@ class BufferSearch {
let scanEnd = Point.ZERO;
let markerIndex = 0;

for (let change of changes) {
for (const change of changes) {
const changeStart = change.start;
const changeEnd = change.start.traverse(change.newExtent);
if (changeEnd.isLessThan(scanEnd)) continue;
Expand All @@ -207,7 +207,7 @@ class BufferSearch {
markerIndex++;
}

let spliceStart, scanStart
let spliceStart; let scanStart
if (precedingMarkerIndex >= 0) {
spliceStart = precedingMarkerIndex;
scanStart = this.markers[precedingMarkerIndex].getBufferRange().start;
Expand All @@ -227,7 +227,7 @@ class BufferSearch {

const newMarkers = this.createMarkers(scanStart, scanEnd) || [];
const oldMarkers = this.markers.splice(spliceStart, (spliceEnd - spliceStart) + 1, ...newMarkers);
for (let oldMarker of oldMarkers) {
for (const oldMarker of oldMarkers) {
oldMarker.destroy();
}
markerIndex += newMarkers.length - oldMarkers.length;
Expand Down
66 changes: 33 additions & 33 deletions lib/find-view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const _ = require('underscore-plus');
const {TextBuffer, TextEditor, CompositeDisposable} = require('atom');
const {TextEditor, CompositeDisposable} = require('atom');
const Util = require('./project/util');
const etch = require('etch');
const $ = etch.dom;
Expand Down Expand Up @@ -211,7 +211,7 @@ class FindView {

didHide() {
this.hideAllTooltips();
let workspaceElement = atom.views.getView(atom.workspace);
const workspaceElement = atom.views.getView(atom.workspace);
workspaceElement.focus();
workspaceElement.classList.remove('find-visible');
}
Expand All @@ -223,7 +223,7 @@ class FindView {

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

this.refs.replaceNextButton.addEventListener('click', e => e.shiftKey ? this.replacePrevious() : this.replaceNext());
this.refs.replaceNextButton.addEventListener('click', e => (e.shiftKey ? this.replacePrevious() : this.replaceNext()));
this.refs.replaceAllButton.addEventListener('click', this.replaceAll.bind(this));
this.subscriptions.add(atom.commands.add('atom-workspace', {
'find-and-replace:replace-previous': this.replacePrevious.bind(this),
Expand Down Expand Up @@ -279,7 +279,7 @@ class FindView {
this.element.addEventListener('focus', () => this.findEditor.element.focus());
this.element.addEventListener('click', (e) => {
if (e.target.tagName === 'button') {
let workspaceElement = atom.views.getView(atom.workspace);
const workspaceElement = atom.views.getView(atom.workspace);
workspaceElement.focus();
}
});
Expand Down Expand Up @@ -325,7 +325,7 @@ class FindView {
}

liveSearch() {
let findPattern = this.findEditor.getText();
const findPattern = this.findEditor.getText();
if (findPattern.length === 0 || (findPattern.length >= atom.config.get('find-and-replace.liveSearchMinimumCharacters') && !this.model.patternMatchesEmptyString(findPattern))) {
return this.model.search(findPattern);
}
Expand Down Expand Up @@ -361,7 +361,7 @@ class FindView {
if (fieldToFocus) {
fieldToFocus.getElement().focus();
} else if (focusEditorAfter) {
let workspaceElement = atom.views.getView(atom.workspace);
const workspaceElement = atom.views.getView(atom.workspace);
workspaceElement.focus();
} else {
this.findEditor.getElement().focus();
Expand All @@ -387,7 +387,7 @@ class FindView {
if (this.markers && this.markers.length > 0) {
let currentMarker = this.model.currentResultMarker;
if (!currentMarker) {
let position = this[nextIndexFn]();
const position = this[nextIndexFn]();
if (position) {
currentMarker = this.markers[position.index];
}
Expand Down Expand Up @@ -419,8 +419,8 @@ class FindView {
this.updateReplaceEnablement();

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

selectFirstMarkerAfterCursor() {
let marker = this.firstMarkerIndexAfterCursor();
const marker = this.firstMarkerIndexAfterCursor();
if (!marker) { return; }
let {index, wrapped} = marker;
const {index, wrapped} = marker;
this.selectMarkerAtIndex(index, wrapped);
}

selectFirstMarkerStartingFromCursor() {
let marker = this.firstMarkerIndexAfterCursor(true);
const marker = this.firstMarkerIndexAfterCursor(true);
if (!marker) { return; }
let {index, wrapped} = marker;
const {index, wrapped} = marker;
this.selectMarkerAtIndex(index, wrapped);
}

selectFirstMarkerBeforeCursor() {
let marker = this.firstMarkerIndexBeforeCursor();
const marker = this.firstMarkerIndexBeforeCursor();
if (!marker) { return; }
let {index, wrapped} = marker;
const {index, wrapped} = marker;
this.selectMarkerAtIndex(index, wrapped);
}

Expand Down Expand Up @@ -541,10 +541,10 @@ class FindView {

selectAllMarkers() {
if (!this.markers || this.markers.length === 0) return;
let ranges = (Array.from(this.markers).map((marker) => marker.getBufferRange()));
let scrollMarker = this.markers[this.firstMarkerIndexAfterCursor().index];
let editor = this.model.getEditor();
for(let range of ranges) {
const ranges = (Array.from(this.markers).map((marker) => marker.getBufferRange()));
const scrollMarker = this.markers[this.firstMarkerIndexAfterCursor().index];
const editor = this.model.getEditor();
for(const range of ranges) {
editor.unfoldBufferRow(range.start.row);
}
editor.setSelectedBufferRanges(ranges, {flash: true});
Expand All @@ -556,9 +556,9 @@ class FindView {
if (!this.markers || this.markers.length === 0) return;

if (marker = this.markers[markerIndex]) {
let editor = this.model.getEditor();
let bufferRange = marker.getBufferRange();
let screenRange = marker.getScreenRange();
const editor = this.model.getEditor();
const bufferRange = marker.getBufferRange();
const screenRange = marker.getScreenRange();

if (
screenRange.start.row < editor.getFirstVisibleScreenRow() ||
Expand All @@ -581,7 +581,7 @@ class FindView {
}

setSelectionAsFindPattern() {
let editor = this.model.getEditor();
const editor = this.model.getEditor();
if (editor && editor.getSelectedText) {
let findPattern = editor.getSelectedText() || editor.getWordUnderCursor();
if (this.model.getFindOptions().useRegex) {
Expand All @@ -598,7 +598,7 @@ class FindView {
}

setSelectionAsReplacePattern() {
let editor = this.model.getEditor();
const editor = this.model.getEditor();
if (editor && editor.getSelectedText) {
let replacePattern = editor.getSelectedText() || editor.getWordUnderCursor();
if (this.model.getFindOptions().useRegex) {
Expand Down Expand Up @@ -678,7 +678,7 @@ class FindView {
}

anyMarkersAreSelected() {
let editor = this.model.getEditor();
const editor = this.model.getEditor();
if (editor) {
return editor.getSelectedBufferRanges().some(selectedRange => {
return this.model.findMarker(selectedRange);
Expand All @@ -703,7 +703,7 @@ class FindView {
toggleSelectionOption() {
this.search({inCurrentSelection: !this.model.getFindOptions().inCurrentSelection});

let editor = this.model.getEditor();
const editor = this.model.getEditor();
if (editor && editor.getSelectedBufferRanges().every(range => range.isEmpty())) {
this.selectFirstMarkerAfterCursor();
}
Expand All @@ -717,9 +717,9 @@ class FindView {
}

updateFindEnablement() {
let editor = this.model.getEditor();
let isDisabled = this.refs.findAllButton.classList.contains('disabled');
let hadFindTooltip = !!this.findTooltipSubscriptions;
const editor = this.model.getEditor();
const isDisabled = this.refs.findAllButton.classList.contains('disabled');
const hadFindTooltip = Boolean(this.findTooltipSubscriptions);

if (hadFindTooltip) this.findTooltipSubscriptions.dispose();
this.findTooltipSubscriptions = new CompositeDisposable;
Expand Down Expand Up @@ -752,7 +752,7 @@ class FindView {
}

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

if (this.replaceTooltipSubscriptions) this.replaceTooltipSubscriptions.dispose();
Expand Down Expand Up @@ -791,10 +791,10 @@ class FindView {

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

let editorView = atom.views.getView(editor);
const editorView = atom.views.getView(editor);
if (!editorView.parentNode) return;
editorView.parentNode.appendChild(this.wrapIcon);

Expand Down
2 changes: 1 addition & 1 deletion lib/find.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BufferSearch = require './buffer-search'
getIconServices = require './get-icon-services'
FindView = require './find-view'
ProjectFindView = require './project-find-view'
ResultsModel = require './project/results-model'
{ResultsModel} = require './project/results-model'
ResultsPaneView = require './project/results-pane'
ReporterProxy = require './reporter-proxy'

Expand Down
Loading