Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 7de77e7

Browse files
committed
chore: fix the types for lint function
1 parent 47643ed commit 7de77e7

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

spec/linter-eslint-spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from 'path'
44
import * as fs from 'fs'
55
import { tmpdir } from 'os'
66
import rimraf from 'rimraf'
7-
import linterEslint from '../dist/main'
7+
import * as linterEslint from '../dist/main'
88

99
import { processESLintMessages } from '../dist/helpers'
1010

@@ -76,6 +76,10 @@ async function getNotification(expectedMessage) {
7676
})
7777
}
7878

79+
/**
80+
* @param {import("atom").TextEditor} textEditor
81+
* @returns {Promise<void>}
82+
*/
7983
async function makeFixes(textEditor) {
8084
const editorReloadPromise = new Promise((resolve) => {
8185
// Subscribe to file reload events
@@ -280,6 +284,10 @@ describe('The eslint provider for Linter', () => {
280284
rimraf.sync(tempDir)
281285
})
282286

287+
/**
288+
* @param {import("atom").TextEditor} textEditor
289+
* @returns {Promise<void>}
290+
*/
283291
async function firstLint(textEditor) {
284292
const messages = await lint(textEditor)
285293
// The original file has two errors
@@ -290,7 +298,6 @@ describe('The eslint provider for Linter', () => {
290298
await firstLint(editor)
291299
await makeFixes(editor)
292300
const messagesAfterFixing = await lint(editor)
293-
294301
expect(messagesAfterFixing.length).toBe(0)
295302
})
296303

src/helpers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export async function generateDebugString() {
160160
* @param {string} [options.severity='error'] Can be one of: 'error', 'warning', 'info'
161161
* @param {string} [options.excerpt=''] Short text to use in the message
162162
* @param {string|Function} [options.description] Used to provide additional information
163-
* @return {Array} Message to user generated from the parameters
163+
* @return {import("atom/linter").Message[]} Message to user generated from the parameters
164164
*/
165165
export function generateUserMessage(textEditor, options) {
166166
const {
@@ -182,9 +182,9 @@ export function generateUserMessage(textEditor, options) {
182182
/**
183183
* Generates a message to the user in order to nicely display the Error being
184184
* thrown instead of depending on generic error handling.
185-
* @param {TextEditor} textEditor The TextEditor to use to build the message
185+
* @param {import("atom").TextEditor} textEditor The TextEditor to use to build the message
186186
* @param {Error} error Error to generate a message for
187-
* @return {Array} Message to user generated from the Error
187+
* @return {import("atom/linter").Message[]} Message to user generated from the Error
188188
*/
189189
export function handleError(textEditor, error) {
190190
const { stack, message } = error

src/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ module.exports = {
173173
grammarScopes: scopes,
174174
scope: 'file',
175175
lintsOnChange: true,
176+
/**
177+
* @param {import("atom").TextEditor} textEditor
178+
* @returns {Promise<import("atom/linter").Message[]>}
179+
*/
176180
lint: async (textEditor) => {
177181
if (!atom.workspace.isTextEditor(textEditor)) {
178182
// If we somehow get fed an invalid TextEditor just immediately return

0 commit comments

Comments
 (0)