Skip to content

Commit 752d4c5

Browse files
committed
refactor: better name
1 parent ea76b68 commit 752d4c5

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

src/linter/context.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const createContext = (file, tree) => {
1818
/**
1919
* Reports a lint issue.
2020
*
21-
* @param {import('./types').ReportIssueProps} issue
21+
* @param {import('./types').IssueDescriptor} descriptor
2222
* @returns {void}
2323
*/
2424
const report = ({ level, message, position }) => {
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
/**
2-
* @type {import('../../types').ReportIssueProps}
2+
* @type {import('../../types').IssueDescriptor}
33
*/
4-
export const infoReport = {
4+
export const infoDescriptor = {
55
level: 'info',
66
message: 'This is a INFO issue',
77
};
88

99
/**
10-
* @type {import('../../types').ReportIssueProps}
10+
* @type {import('../../types').IssueDescriptor}
1111
*/
12-
export const warnReport = {
12+
export const warnDescriptor = {
1313
level: 'warn',
1414
message: 'This is a WARN issue',
1515
position: { start: { line: 1, column: 1 }, end: { line: 1, column: 2 } },
1616
};
1717

1818
/**
19-
* @type {import('../../types').ReportIssueProps}
19+
* @type {import('../../types').IssueDescriptor}
2020
*/
21-
export const errorReport = {
21+
export const errorDescriptor = {
2222
level: 'error',
2323
message: 'This is a ERROR issue',
2424
position: { start: { line: 1, column: 1 }, end: { line: 1, column: 2 } },

src/linter/tests/index.test.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { describe, mock, it } from 'node:test';
22
import assert from 'node:assert/strict';
3+
import { VFile } from 'vfile';
4+
35
import createLinter from '../index.mjs';
46
import { errorIssue, infoIssue, warnIssue } from './fixtures/issues.mjs';
5-
import { VFile } from 'vfile';
67
import createContext from '../context.mjs';
7-
import { errorReport, infoReport, warnReport } from './fixtures/report.mjs';
8+
import {
9+
errorDescriptor,
10+
infoDescriptor,
11+
warnDescriptor,
12+
} from './fixtures/descriptors.mjs';
813
import { emptyTree } from './fixtures/tree.mjs';
914

1015
describe('createLinter', () => {
@@ -33,11 +38,11 @@ describe('createLinter', () => {
3338

3439
it('should return the aggregated issues from all rules', () => {
3540
const rule1 = mock.fn(ctx => {
36-
ctx.report(infoReport);
37-
ctx.report(warnReport);
41+
ctx.report(infoDescriptor);
42+
ctx.report(warnDescriptor);
3843
});
3944

40-
const rule2 = mock.fn(ctx => ctx.report(errorReport));
45+
const rule2 = mock.fn(ctx => ctx.report(errorDescriptor));
4146

4247
const linter = createLinter([rule1, rule2]);
4348

src/linter/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ export interface Linter {
2727
hasError: () => boolean;
2828
}
2929

30-
export interface ReportIssueProps {
30+
export interface IssueDescriptor {
3131
level: IssueLevel;
3232
message: string;
3333
position?: Position;
3434
}
3535

3636
export interface LintContext {
3737
readonly tree: Root;
38-
report(issue: ReportIssueProps): void;
38+
report(descriptor: IssueDescriptor): void;
3939
getIssues(): LintIssue[];
4040
}

0 commit comments

Comments
 (0)