Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ember-template-lint/todo-utils

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ember-template-lint/todo-utils - npm Package Compare versions

Comparing version 9.1.2 to 10.0.0-beta.0

lib/todo-batch-generator.d.ts

19

CHANGELOG.md

@@ -0,1 +1,20 @@

## v10.0.0-beta.0 (2021-07-20)
#### :boom: Breaking Change
* [#264](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/264) Adding test cases for fuzzy matching ([@scalvert](https://github.com/scalvert))
* [#252](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/252) Adding expanded todo batching functionality to account for fuzzy matching ([@scalvert](https://github.com/scalvert))
* [#250](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/250) Renaming FilePath type to improve code readability ([@scalvert](https://github.com/scalvert))
#### :rocket: Enhancement
* [#264](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/264) Adding test cases for fuzzy matching ([@scalvert](https://github.com/scalvert))
* [#257](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/257) Expands todo data into v2 format ([@scalvert](https://github.com/scalvert))
* [#252](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/252) Adding expanded todo batching functionality to account for fuzzy matching ([@scalvert](https://github.com/scalvert))
#### :house: Internal
* [#250](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/250) Renaming FilePath type to improve code readability ([@scalvert](https://github.com/scalvert))
#### Committers: 1
- Steve Calvert ([@scalvert](https://github.com/scalvert))
## v9.1.2 (2021-06-10)

@@ -2,0 +21,0 @@

12

lib/builders.d.ts

@@ -1,4 +0,4 @@

import { FilePath, LintMessage, LintResult, TodoConfig, TodoData } from './types';
import { LintMessage, LintResult, TodoConfig, TodoData, TodoDataV2 } from './types';
/**
* Adapts a list of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32|LintResult} to a map of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}, {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* Adapts a list of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32|LintResult} to a map of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|TodoFileHash}, {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*

@@ -8,5 +8,5 @@ * @param baseDir - The base directory that contains the .lint-todo storage directory.

* @param todoConfig - An object containing the warn or error days, in integers.
* @returns - A Promise resolving to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A Promise resolving to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set|Set} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
export declare function buildTodoData(baseDir: string, lintResults: LintResult[], todoConfig?: TodoConfig): Map<FilePath, TodoData>;
export declare function buildTodoData(baseDir: string, lintResults: LintResult[], todoConfig?: TodoConfig): Set<TodoDataV2>;
/**

@@ -22,3 +22,5 @@ * Adapts an {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32|LintResult} to a {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}. FilePaths are absolute

*/
export declare function _buildTodoDatum(baseDir: string, lintResult: LintResult, lintMessage: LintMessage, todoConfig?: TodoConfig): TodoData;
export declare function buildTodoDatum(baseDir: string, lintResult: LintResult, lintMessage: LintMessage, todoConfig?: TodoConfig): TodoDataV2;
export declare function normalizeToV2(todoDatum: TodoData): TodoDataV2;
export declare function generateHash(input: string, algorithm?: string): string;
//# sourceMappingURL=builders.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._buildTodoDatum = exports.buildTodoData = void 0;
exports.generateHash = exports.normalizeToV2 = exports.buildTodoDatum = exports.buildTodoData = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const slash = require("slash");
const io_1 = require("./io");
const types_1 = require("./types");
const date_utils_1 = require("./date-utils");
const LINES_PATTERN = /(.*?(?:\r\n?|\n|$))/gm;
/**
* Adapts a list of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32|LintResult} to a map of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}, {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* Adapts a list of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32|LintResult} to a map of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|TodoFileHash}, {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*

@@ -14,3 +16,3 @@ * @param baseDir - The base directory that contains the .lint-todo storage directory.

* @param todoConfig - An object containing the warn or error days, in integers.
* @returns - A Promise resolving to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A Promise resolving to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set|Set} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/

@@ -22,8 +24,8 @@ function buildTodoData(baseDir, lintResults, todoConfig) {

if (message.severity === 2) {
const todoDatum = _buildTodoDatum(baseDir, lintResult, message, todoConfig);
converted.set(io_1.todoFilePathFor(todoDatum), todoDatum);
const todoDatum = buildTodoDatum(baseDir, lintResult, message, todoConfig);
converted.add(todoDatum);
}
});
return converted;
}, new Map());
}, new Set());
return todoData;

@@ -42,3 +44,3 @@ }

*/
function _buildTodoDatum(baseDir, lintResult, lintMessage, todoConfig) {
function buildTodoDatum(baseDir, lintResult, lintMessage, todoConfig) {
// Note: If https://github.com/nodejs/node/issues/13683 is fixed, remove slash() and use posix.relative

@@ -51,2 +53,3 @@ // provided that the fix is landed on the supported node versions of this lib

const ruleId = getRuleId(lintMessage);
const range = getRange(lintMessage);
const todoDatum = {

@@ -56,5 +59,6 @@ engine: getEngine(lintResult),

ruleId: getRuleId(lintMessage),
line: lintMessage.line,
column: lintMessage.column,
range,
source: getSource(lintResult, lintMessage, range),
createdDate: createdDate.getTime(),
fileFormat: types_1.TodoFileFormat.Version2,
};

@@ -70,3 +74,84 @@ const daysToDecay = getDaysToDecay(ruleId, todoConfig);

}
exports._buildTodoDatum = _buildTodoDatum;
exports.buildTodoDatum = buildTodoDatum;
function normalizeToV2(todoDatum) {
// if we have a range property, we're already in V2 format
if ('range' in todoDatum) {
todoDatum.fileFormat = types_1.TodoFileFormat.Version2;
return todoDatum;
}
const todoDatumV1 = todoDatum;
const todoDatumV2 = {
engine: todoDatumV1.engine,
filePath: todoDatumV1.filePath,
ruleId: todoDatumV1.ruleId,
range: getRange(todoDatumV1),
source: '',
createdDate: todoDatumV1.createdDate,
fileFormat: types_1.TodoFileFormat.Version1,
};
if (todoDatumV1.warnDate) {
todoDatumV2.warnDate = todoDatumV1.warnDate;
}
if (todoDatumV1.errorDate) {
todoDatumV2.errorDate = todoDatumV1.errorDate;
}
return todoDatumV2;
}
exports.normalizeToV2 = normalizeToV2;
function generateHash(input, algorithm = 'sha1') {
return crypto_1.createHash(algorithm).update(input).digest('hex');
}
exports.generateHash = generateHash;
function getRange(loc) {
var _a, _b;
return {
start: {
line: loc.line,
column: loc.column,
},
end: {
// eslint-disable-next-line unicorn/no-null
line: (_a = loc.endLine) !== null && _a !== void 0 ? _a : loc.line,
// eslint-disable-next-line unicorn/no-null
column: (_b = loc.endColumn) !== null && _b !== void 0 ? _b : loc.column,
},
};
}
function getSource(lintResult, lintMessage, range) {
if (lintResult.source) {
return generateHash(getSourceForRange(lintResult.source.match(LINES_PATTERN) || [], range));
}
if (lintMessage.source) {
return generateHash(lintMessage.source);
}
return '';
}
function getSourceForRange(source, range) {
const firstLine = range.start.line - 1;
const lastLine = range.end.line - 1;
let currentLine = firstLine - 1;
const firstColumn = range.start.column - 1;
const lastColumn = range.end.column - 1;
const string = [];
let line;
while (currentLine < lastLine) {
currentLine++;
line = source[currentLine];
if (currentLine === firstLine) {
if (firstLine === lastLine) {
string.push(line.slice(firstColumn, lastColumn));
}
else {
string.push(line.slice(firstColumn));
}
}
else if (currentLine === lastLine) {
string.push(line.slice(0, lastColumn));
}
else {
string.push(line);
}
}
return string.join('');
}
function getDaysToDecay(ruleId, todoConfig) {

@@ -73,0 +158,0 @@ if (!todoConfig) {

@@ -1,2 +0,2 @@

import { Severity, TodoData } from './types';
import { Severity, TodoDataV2 } from './types';
/**

@@ -9,3 +9,3 @@ * Returns the correct severity level based on the todo data's decay dates.

*/
export declare function getSeverity(todo: TodoData, today?: number): Severity;
export declare function getSeverity(todo: TodoDataV2, today?: number): Severity;
//# sourceMappingURL=get-severity.d.ts.map

@@ -1,7 +0,7 @@

export { _buildTodoDatum, buildTodoData } from './builders';
export { applyTodoChanges, ensureTodoStorageDir, getTodoStorageDirPath, getTodoBatches, todoStorageDirExists, todoDirFor, todoFileNameFor, todoFilePathFor, readTodos, readTodosForFilePath, writeTodos, applyTodoChangesSync, ensureTodoStorageDirSync, getTodoBatchesSync, readTodosSync, readTodosForFilePathSync, writeTodosSync, } from './io';
export { buildTodoData, buildTodoDatum } from './builders';
export { applyTodoChanges, ensureTodoStorageDir, getTodoStorageDirPath, readTodos, readTodosForFilePath, todoStorageDirExists, todoDirFor, todoFileNameFor, todoFilePathFor, writeTodos, } from './io';
export { getTodoConfig, validateConfig } from './todo-config';
export { getSeverity } from './get-severity';
export { getDatePart, isExpired, differenceInDays, format } from './date-utils';
export { differenceInDays, format, getDatePart, isExpired } from './date-utils';
export * from './types';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = exports.differenceInDays = exports.isExpired = exports.getDatePart = exports.getSeverity = exports.validateConfig = exports.getTodoConfig = exports.writeTodosSync = exports.readTodosForFilePathSync = exports.readTodosSync = exports.getTodoBatchesSync = exports.ensureTodoStorageDirSync = exports.applyTodoChangesSync = exports.writeTodos = exports.readTodosForFilePath = exports.readTodos = exports.todoFilePathFor = exports.todoFileNameFor = exports.todoDirFor = exports.todoStorageDirExists = exports.getTodoBatches = exports.getTodoStorageDirPath = exports.ensureTodoStorageDir = exports.applyTodoChanges = exports.buildTodoData = exports._buildTodoDatum = void 0;
exports.isExpired = exports.getDatePart = exports.format = exports.differenceInDays = exports.getSeverity = exports.validateConfig = exports.getTodoConfig = exports.writeTodos = exports.todoFilePathFor = exports.todoFileNameFor = exports.todoDirFor = exports.todoStorageDirExists = exports.readTodosForFilePath = exports.readTodos = exports.getTodoStorageDirPath = exports.ensureTodoStorageDir = exports.applyTodoChanges = exports.buildTodoDatum = exports.buildTodoData = void 0;
const tslib_1 = require("tslib");
var builders_1 = require("./builders");
Object.defineProperty(exports, "_buildTodoDatum", { enumerable: true, get: function () { return builders_1._buildTodoDatum; } });
Object.defineProperty(exports, "buildTodoData", { enumerable: true, get: function () { return builders_1.buildTodoData; } });
Object.defineProperty(exports, "buildTodoDatum", { enumerable: true, get: function () { return builders_1.buildTodoDatum; } });
var io_1 = require("./io");

@@ -12,3 +12,4 @@ Object.defineProperty(exports, "applyTodoChanges", { enumerable: true, get: function () { return io_1.applyTodoChanges; } });

Object.defineProperty(exports, "getTodoStorageDirPath", { enumerable: true, get: function () { return io_1.getTodoStorageDirPath; } });
Object.defineProperty(exports, "getTodoBatches", { enumerable: true, get: function () { return io_1.getTodoBatches; } });
Object.defineProperty(exports, "readTodos", { enumerable: true, get: function () { return io_1.readTodos; } });
Object.defineProperty(exports, "readTodosForFilePath", { enumerable: true, get: function () { return io_1.readTodosForFilePath; } });
Object.defineProperty(exports, "todoStorageDirExists", { enumerable: true, get: function () { return io_1.todoStorageDirExists; } });

@@ -18,11 +19,3 @@ Object.defineProperty(exports, "todoDirFor", { enumerable: true, get: function () { return io_1.todoDirFor; } });

Object.defineProperty(exports, "todoFilePathFor", { enumerable: true, get: function () { return io_1.todoFilePathFor; } });
Object.defineProperty(exports, "readTodos", { enumerable: true, get: function () { return io_1.readTodos; } });
Object.defineProperty(exports, "readTodosForFilePath", { enumerable: true, get: function () { return io_1.readTodosForFilePath; } });
Object.defineProperty(exports, "writeTodos", { enumerable: true, get: function () { return io_1.writeTodos; } });
Object.defineProperty(exports, "applyTodoChangesSync", { enumerable: true, get: function () { return io_1.applyTodoChangesSync; } });
Object.defineProperty(exports, "ensureTodoStorageDirSync", { enumerable: true, get: function () { return io_1.ensureTodoStorageDirSync; } });
Object.defineProperty(exports, "getTodoBatchesSync", { enumerable: true, get: function () { return io_1.getTodoBatchesSync; } });
Object.defineProperty(exports, "readTodosSync", { enumerable: true, get: function () { return io_1.readTodosSync; } });
Object.defineProperty(exports, "readTodosForFilePathSync", { enumerable: true, get: function () { return io_1.readTodosForFilePathSync; } });
Object.defineProperty(exports, "writeTodosSync", { enumerable: true, get: function () { return io_1.writeTodosSync; } });
var todo_config_1 = require("./todo-config");

@@ -34,7 +27,7 @@ Object.defineProperty(exports, "getTodoConfig", { enumerable: true, get: function () { return todo_config_1.getTodoConfig; } });

var date_utils_1 = require("./date-utils");
Object.defineProperty(exports, "differenceInDays", { enumerable: true, get: function () { return date_utils_1.differenceInDays; } });
Object.defineProperty(exports, "format", { enumerable: true, get: function () { return date_utils_1.format; } });
Object.defineProperty(exports, "getDatePart", { enumerable: true, get: function () { return date_utils_1.getDatePart; } });
Object.defineProperty(exports, "isExpired", { enumerable: true, get: function () { return date_utils_1.isExpired; } });
Object.defineProperty(exports, "differenceInDays", { enumerable: true, get: function () { return date_utils_1.differenceInDays; } });
Object.defineProperty(exports, "format", { enumerable: true, get: function () { return date_utils_1.format; } });
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

import { FilePath, LintResult, TodoData, TodoBatchCounts, WriteTodoOptions } from './types';
import { TodoFileHash, LintResult, TodoDataV2, TodoBatchCounts, WriteTodoOptions, TodoFilePathHash, TodoBatches } from './types';
import TodoMatcher from './todo-matcher';
/**

@@ -15,12 +16,5 @@ * Determines if the .lint-todo storage directory exists.

*/
export declare function ensureTodoStorageDirSync(baseDir: string): string;
export declare function ensureTodoStorageDir(baseDir: string): string;
/**
* Creates, or ensures the creation of, the .lint-todo directory.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A promise that resolves to the todo storage directory path.
*/
export declare function ensureTodoStorageDir(baseDir: string): Promise<string>;
/**
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - The todo storage directory path.

@@ -39,3 +33,3 @@ */

*/
export declare function todoFilePathFor(todoData: TodoData): string;
export declare function todoFilePathFor(todoData: TodoDataV2): string;
/**

@@ -54,3 +48,3 @@ * Creates a short hash for the todo's file path.

*/
export declare function todoFileNameFor(todoData: TodoData): string;
export declare function todoFileNameFor(todoData: TodoDataV2): string;
/**

@@ -68,31 +62,11 @@ * Writes files for todo lint violations. One file is generated for each violation, using a generated

*/
export declare function writeTodosSync(baseDir: string, lintResults: LintResult[], options?: Partial<WriteTodoOptions>): TodoBatchCounts;
export declare function writeTodos(baseDir: string, lintResults: LintResult[], options?: Partial<WriteTodoOptions>): TodoBatchCounts;
/**
* Writes files for todo lint violations. One file is generated for each violation, using a generated
* hash to identify each.
*
* Given a list of todo lint violations, this function will also delete existing files that no longer
* have a todo lint violation.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param lintResults - The raw linting data.
* @param options - An object containing write options.
* @returns - A promise that resolves to the counts of added and removed todos.
*/
export declare function writeTodos(baseDir: string, lintResults: LintResult[], options?: Partial<WriteTodoOptions>): Promise<TodoBatchCounts>;
/**
* Reads all todo files in the .lint-todo directory.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L51|TodoFilePathHash}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/todo-matcher.ts#L4|TodoMatcher}.
*/
export declare function readTodosSync(baseDir: string): Map<FilePath, TodoData>;
export declare function readTodos(baseDir: string): Map<TodoFilePathHash, TodoMatcher>;
/**
* Reads all todo files in the .lint-todo directory.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A Promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
export declare function readTodos(baseDir: string): Promise<Map<FilePath, TodoData>>;
/**
* Reads todo files in the .lint-todo directory for a specific filePath.

@@ -102,30 +76,14 @@ *

* @param filePath - The relative file path of the file to return todo items for.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L51|TodoFilePathHash}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/todo-matcher.ts#L4|TodoMatcher}.
*/
export declare function readTodosForFilePathSync(baseDir: string, filePath: string): Map<FilePath, TodoData>;
export declare function readTodosForFilePath(baseDir: string, filePath: string): Map<TodoFilePathHash, TodoMatcher>;
/**
* Reads todo files in the .lint-todo directory for a specific filePath.
* Gets 4 maps containing todo items to add, remove, those that are expired, or those that are stable (not to be modified).
*
* @param todoStorageDir - The .lint-todo storage directory.
* @param filePath - The relative file path of the file to return todo items for.
* @returns - A Promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
export declare function readTodosForFilePath(baseDir: string, filePath: string): Promise<Map<FilePath, TodoData>>;
/**
* Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
*
* @param lintResults - The linting data for all violations.
* @param existing - Existing todo lint data.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|TodoFileHash}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
export declare function getTodoBatchesSync(lintResults: Map<FilePath, TodoData>, existing: Map<FilePath, TodoData>, options: Partial<WriteTodoOptions>): Map<FilePath, TodoData>[];
export declare function getTodoBatches(baseDir: string, lintResults: LintResult[], existing: Map<TodoFilePathHash, TodoMatcher>, options: Partial<WriteTodoOptions>): TodoBatches;
/**
* Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
*
* @param lintResults - The linting data for all violations.
* @param existing - Existing todo lint data.
* @returns - A Promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
export declare function getTodoBatches(lintResults: Map<FilePath, TodoData>, existing: Map<FilePath, TodoData>, options: Partial<WriteTodoOptions>): Promise<Map<FilePath, TodoData>[]>;
/**
* Applies todo changes, either adding or removing, based on batches from `getTodoBatches`.

@@ -137,11 +95,3 @@ *

*/
export declare function applyTodoChangesSync(todoStorageDir: string, add: Map<FilePath, TodoData>, remove: Map<FilePath, TodoData>): void;
/**
* Applies todo changes, either adding or removing, based on batches from `getTodoBatches`.
*
* @param todoStorageDir - The .lint-todo storage directory.
* @param add - Batch of todos to add.
* @param remove - Batch of todos to remove.
*/
export declare function applyTodoChanges(todoStorageDir: string, add: Map<FilePath, TodoData>, remove: Map<FilePath, TodoData>): Promise<void>;
export declare function applyTodoChanges(todoStorageDir: string, add: Map<TodoFileHash, TodoDataV2>, remove: Set<TodoFileHash>): void;
//# sourceMappingURL=io.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyTodoChanges = exports.applyTodoChangesSync = exports.getTodoBatches = exports.getTodoBatchesSync = exports.readTodosForFilePath = exports.readTodosForFilePathSync = exports.readTodos = exports.readTodosSync = exports.writeTodos = exports.writeTodosSync = exports.todoFileNameFor = exports.todoDirFor = exports.todoFilePathFor = exports.getTodoStorageDirPath = exports.ensureTodoStorageDir = exports.ensureTodoStorageDirSync = exports.todoStorageDirExists = void 0;
exports.applyTodoChanges = exports.getTodoBatches = exports.readTodosForFilePath = exports.readTodos = exports.writeTodos = exports.todoFileNameFor = exports.todoDirFor = exports.todoFilePathFor = exports.getTodoStorageDirPath = exports.ensureTodoStorageDir = exports.todoStorageDirExists = void 0;
const tslib_1 = require("tslib");
/* eslint-disable @typescript-eslint/no-non-null-assertion */
const crypto_1 = require("crypto");
const path_1 = require("path");
const fs_extra_1 = require("fs-extra");
const todo_matcher_1 = tslib_1.__importDefault(require("./todo-matcher"));
const todo_batch_generator_1 = tslib_1.__importDefault(require("./todo-batch-generator"));
const builders_1 = require("./builders");
const date_utils_1 = require("./date-utils");
/**

@@ -26,3 +27,3 @@ * Determines if the .lint-todo storage directory exists.

*/
function ensureTodoStorageDirSync(baseDir) {
function ensureTodoStorageDir(baseDir) {
const path = getTodoStorageDirPath(baseDir);

@@ -32,14 +33,2 @@ fs_extra_1.ensureDirSync(path);

}
exports.ensureTodoStorageDirSync = ensureTodoStorageDirSync;
/**
* Creates, or ensures the creation of, the .lint-todo directory.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A promise that resolves to the todo storage directory path.
*/
async function ensureTodoStorageDir(baseDir) {
const path = getTodoStorageDirPath(baseDir);
await fs_extra_1.ensureDir(path);
return path;
}
exports.ensureTodoStorageDir = ensureTodoStorageDir;

@@ -75,3 +64,3 @@ /**

function todoDirFor(filePath) {
return crypto_1.createHash('sha1').update(filePath).digest('hex');
return builders_1.generateHash(filePath);
}

@@ -86,4 +75,4 @@ exports.todoDirFor = todoDirFor;

function todoFileNameFor(todoData) {
const hashParams = `${todoData.engine}${todoData.ruleId}${todoData.line}${todoData.column}`;
return crypto_1.createHash('sha256').update(hashParams).digest('hex').slice(0, 8);
const fileContentsHash = `${todoData.engine}${todoData.ruleId}${todoData.range.start.line}${todoData.range.start.column}`;
return builders_1.generateHash(fileContentsHash, 'sha256').slice(0, 8);
}

@@ -103,37 +92,12 @@ exports.todoFileNameFor = todoFileNameFor;

*/
function writeTodosSync(baseDir, lintResults, options) {
function writeTodos(baseDir, lintResults, options) {
options = Object.assign({ shouldRemove: () => true }, options !== null && options !== void 0 ? options : {});
const todoStorageDir = ensureTodoStorageDirSync(baseDir);
const todoStorageDir = ensureTodoStorageDir(baseDir);
const existing = options.filePath
? readTodosForFilePathSync(baseDir, options.filePath)
: readTodosSync(baseDir);
// eslint-disable-next-line prefer-const
let [add, remove] = getTodoBatchesSync(builders_1.buildTodoData(baseDir, lintResults, options.todoConfig), existing, options);
applyTodoChangesSync(todoStorageDir, add, remove);
return [add.size, remove.size];
? readTodosForFilePath(baseDir, options.filePath)
: readTodos(baseDir);
const { add, remove, stable, expired } = getTodoBatches(baseDir, lintResults, existing, options);
applyTodoChanges(todoStorageDir, add, remove);
return [add.size, remove.size, stable.size, expired.size];
}
exports.writeTodosSync = writeTodosSync;
/**
* Writes files for todo lint violations. One file is generated for each violation, using a generated
* hash to identify each.
*
* Given a list of todo lint violations, this function will also delete existing files that no longer
* have a todo lint violation.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param lintResults - The raw linting data.
* @param options - An object containing write options.
* @returns - A promise that resolves to the counts of added and removed todos.
*/
async function writeTodos(baseDir, lintResults, options) {
options = Object.assign({ shouldRemove: () => true }, options !== null && options !== void 0 ? options : {});
const todoStorageDir = await ensureTodoStorageDir(baseDir);
const existing = options.filePath
? await readTodosForFilePath(baseDir, options.filePath)
: await readTodos(baseDir);
// eslint-disable-next-line prefer-const
let [add, remove] = await getTodoBatches(builders_1.buildTodoData(baseDir, lintResults, options.todoConfig), existing, options);
await applyTodoChanges(todoStorageDir, add, remove);
return [add.size, remove.size];
}
exports.writeTodos = writeTodos;

@@ -144,36 +108,20 @@ /**

* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L51|TodoFilePathHash}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/todo-matcher.ts#L4|TodoMatcher}.
*/
function readTodosSync(baseDir) {
const map = new Map();
const todoStorageDir = ensureTodoStorageDirSync(baseDir);
function readTodos(baseDir) {
const existingTodos = new Map();
const todoStorageDir = ensureTodoStorageDir(baseDir);
const todoFileDirs = fs_extra_1.readdirSync(todoStorageDir);
for (const todoFileDir of todoFileDirs) {
const fileNames = fs_extra_1.readdirSync(path_1.posix.join(todoStorageDir, todoFileDir));
for (const fileName of fileNames) {
const todo = fs_extra_1.readJSONSync(path_1.posix.join(todoStorageDir, todoFileDir, fileName));
map.set(path_1.posix.join(todoFileDir, path_1.posix.parse(fileName).name), todo);
const todoFileHashes = fs_extra_1.readdirSync(path_1.posix.join(todoStorageDir, todoFileDir));
if (!existingTodos.has(todoFileDir)) {
existingTodos.set(todoFileDir, new todo_matcher_1.default());
}
}
return map;
}
exports.readTodosSync = readTodosSync;
/**
* Reads all todo files in the .lint-todo directory.
*
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A Promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
async function readTodos(baseDir) {
const map = new Map();
const todoStorageDir = await ensureTodoStorageDir(baseDir);
const todoFileDirs = await fs_extra_1.readdir(todoStorageDir);
for (const todoFileDir of todoFileDirs) {
const fileNames = await fs_extra_1.readdir(path_1.posix.join(todoStorageDir, todoFileDir));
for (const fileName of fileNames) {
const todo = await fs_extra_1.readJSON(path_1.posix.join(todoStorageDir, todoFileDir, fileName));
map.set(path_1.posix.join(todoFileDir, path_1.posix.parse(fileName).name), todo);
const matcher = existingTodos.get(todoFileDir);
for (const todoFileHash of todoFileHashes) {
const todoDatum = fs_extra_1.readJSONSync(path_1.posix.join(todoStorageDir, todoFileDir, todoFileHash));
matcher.add(builders_1.normalizeToV2(todoDatum));
}
}
return map;
return existingTodos;
}

@@ -186,14 +134,18 @@ exports.readTodos = readTodos;

* @param filePath - The relative file path of the file to return todo items for.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L51|TodoFilePathHash}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/todo-matcher.ts#L4|TodoMatcher}.
*/
function readTodosForFilePathSync(baseDir, filePath) {
const map = new Map();
const todoStorageDir = ensureTodoStorageDirSync(baseDir);
function readTodosForFilePath(baseDir, filePath) {
const existingTodos = new Map();
const todoStorageDir = ensureTodoStorageDir(baseDir);
const todoFileDir = todoDirFor(filePath);
const todoFilePathDir = path_1.posix.join(todoStorageDir, todoFileDir);
try {
if (!existingTodos.has(todoFileDir)) {
existingTodos.set(todoFileDir, new todo_matcher_1.default());
}
const matcher = existingTodos.get(todoFileDir);
const fileNames = fs_extra_1.readdirSync(todoFilePathDir);
for (const fileName of fileNames) {
const todo = fs_extra_1.readJSONSync(path_1.posix.join(todoFilePathDir, fileName));
map.set(path_1.posix.join(todoFileDir, path_1.posix.parse(fileName).name), todo);
const todoDatum = fs_extra_1.readJSONSync(path_1.posix.join(todoFilePathDir, fileName));
matcher === null || matcher === void 0 ? void 0 : matcher.add(builders_1.normalizeToV2(todoDatum));
}

@@ -203,114 +155,20 @@ }

if (error.code === 'ENOENT') {
return map;
return existingTodos;
}
throw error;
}
return map;
return existingTodos;
}
exports.readTodosForFilePathSync = readTodosForFilePathSync;
/**
* Reads todo files in the .lint-todo directory for a specific filePath.
*
* @param todoStorageDir - The .lint-todo storage directory.
* @param filePath - The relative file path of the file to return todo items for.
* @returns - A Promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
async function readTodosForFilePath(baseDir, filePath) {
const map = new Map();
const todoStorageDir = await ensureTodoStorageDir(baseDir);
const todoFileDir = todoDirFor(filePath);
const todoFilePathDir = path_1.posix.join(todoStorageDir, todoFileDir);
try {
const fileNames = await fs_extra_1.readdir(todoFilePathDir);
for (const fileName of fileNames) {
const todo = await fs_extra_1.readJSON(path_1.posix.join(todoFilePathDir, fileName));
map.set(path_1.posix.join(todoFileDir, path_1.posix.parse(fileName).name), todo);
}
}
catch (error) {
if (error.code === 'ENOENT') {
return map;
}
throw error;
}
return map;
}
exports.readTodosForFilePath = readTodosForFilePath;
/**
* Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
* Gets 4 maps containing todo items to add, remove, those that are expired, or those that are stable (not to be modified).
*
* @param lintResults - The linting data for all violations.
* @param existing - Existing todo lint data.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
* @returns - A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|TodoFileHash}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
function getTodoBatchesSync(lintResults, existing, options) {
const add = new Map();
const remove = new Map();
const expired = new Map();
const stable = new Map();
for (const [fileHash, todoDatum] of lintResults) {
if (!existing.has(fileHash)) {
add.set(fileHash, todoDatum);
}
else {
const existingTodo = existing.get(fileHash);
if (existingTodo && !date_utils_1.isExpired(existingTodo.errorDate)) {
stable.set(fileHash, todoDatum);
}
}
}
for (const [fileHash, todoDatum] of existing) {
if (lintResults.has(fileHash) &&
date_utils_1.isExpired(todoDatum.errorDate) &&
options.shouldRemove(todoDatum)) {
expired.set(fileHash, todoDatum);
}
else if (!lintResults.has(fileHash) && options.shouldRemove(todoDatum)) {
remove.set(fileHash, todoDatum);
}
else {
stable.set(fileHash, todoDatum);
}
}
return [add, remove, stable, expired];
function getTodoBatches(baseDir, lintResults, existing, options) {
const todoBatchGenerator = new todo_batch_generator_1.default(baseDir, options);
return todoBatchGenerator.generate(lintResults, existing);
}
exports.getTodoBatchesSync = getTodoBatchesSync;
/**
* Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
*
* @param lintResults - The linting data for all violations.
* @param existing - Existing todo lint data.
* @returns - A Promise that resolves to a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|Map} of {@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35|FilePath}/{@link https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36|TodoData}.
*/
async function getTodoBatches(lintResults, existing, options) {
const add = new Map();
const remove = new Map();
const expired = new Map();
const stable = new Map();
for (const [fileHash, todoDatum] of lintResults) {
if (!existing.has(fileHash)) {
add.set(fileHash, todoDatum);
}
else {
const existingTodo = existing.get(fileHash);
if (existingTodo && !date_utils_1.isExpired(existingTodo.errorDate)) {
stable.set(fileHash, todoDatum);
}
}
}
for (const [fileHash, todoDatum] of existing) {
if (lintResults.has(fileHash) &&
date_utils_1.isExpired(todoDatum.errorDate) &&
options.shouldRemove(todoDatum)) {
expired.set(fileHash, todoDatum);
}
else if (!lintResults.has(fileHash) && options.shouldRemove(todoDatum)) {
remove.set(fileHash, todoDatum);
}
else {
stable.set(fileHash, todoDatum);
}
}
return [add, remove, stable, expired];
}
exports.getTodoBatches = getTodoBatches;

@@ -324,3 +182,3 @@ /**

*/
function applyTodoChangesSync(todoStorageDir, add, remove) {
function applyTodoChanges(todoStorageDir, add, remove) {
for (const [fileHash, todoDatum] of add) {

@@ -331,3 +189,3 @@ const { dir } = path_1.posix.parse(fileHash);

}
for (const [fileHash] of remove) {
for (const fileHash of remove) {
const { dir } = path_1.posix.parse(fileHash);

@@ -341,26 +199,3 @@ const todoDir = path_1.posix.join(todoStorageDir, dir);

}
exports.applyTodoChangesSync = applyTodoChangesSync;
/**
* Applies todo changes, either adding or removing, based on batches from `getTodoBatches`.
*
* @param todoStorageDir - The .lint-todo storage directory.
* @param add - Batch of todos to add.
* @param remove - Batch of todos to remove.
*/
async function applyTodoChanges(todoStorageDir, add, remove) {
for (const [fileHash, todoDatum] of add) {
const { dir } = path_1.posix.parse(fileHash);
await fs_extra_1.ensureDir(path_1.posix.join(todoStorageDir, dir));
await fs_extra_1.writeJson(path_1.posix.join(todoStorageDir, `${fileHash}.json`), todoDatum);
}
for (const [fileHash] of remove) {
const { dir } = path_1.posix.parse(fileHash);
const todoDir = path_1.posix.join(todoStorageDir, dir);
await fs_extra_1.unlink(path_1.posix.join(todoStorageDir, `${fileHash}.json`));
if ((await fs_extra_1.readdir(todoDir)).length === 0) {
await fs_extra_1.rmdir(todoDir);
}
}
}
exports.applyTodoChanges = applyTodoChanges;
//# sourceMappingURL=io.js.map

@@ -1,71 +0,3 @@

import { ESLint, Linter } from 'eslint';
import { PackageJson } from 'type-fest';
export declare enum Severity {
todo = -1,
off = 0,
warn = 1,
error = 2
}
export interface TemplateLintReport {
results: TemplateLintResult[];
errorCount: number;
}
export interface TemplateLintResult {
filePath: string;
messages: TemplateLintMessage[];
errorCount: number;
source: string;
}
export interface TemplateLintMessage {
rule: string;
severity: 0 | 1 | 2;
moduleId: string;
message: string;
line: number;
column: number;
source: string;
}
export declare type LintResult = ESLint.LintResult | TemplateLintResult;
export declare type LintMessage = Linter.LintMessage | TemplateLintMessage;
export declare type FilePath = string;
export interface TodoData {
engine: 'eslint' | 'ember-template-lint';
filePath: string;
ruleId: string;
line: number;
column: number;
createdDate: number;
warnDate?: number;
errorDate?: number;
}
export declare type LintTodoPackageJson = PackageJson & {
lintTodo?: TodoConfig | TodoConfigByEngine;
};
export declare type TodoBatchCounts = [number, number];
export declare type DaysToDecay = {
warn?: number;
error?: number;
};
export declare type DaysToDecayByRule = {
[ruleId: string]: DaysToDecay;
};
export interface TodoConfig {
daysToDecay?: DaysToDecay;
daysToDecayByRule?: DaysToDecayByRule;
}
export interface TodoConfigByEngine {
[engine: string]: TodoConfig;
}
/**
* An optional configuration object passed to writeTodos.
*
* @param filePath - The relative file path of the file to update violations for.
* @param todoConfig - An object containing the warn or error days, in integers.
* @param skipRemoval - Allows for skipping removal of todo files.
*/
export interface WriteTodoOptions {
filePath: string;
todoConfig: TodoConfig;
shouldRemove: (todoDatum: TodoData) => boolean;
}
export * from './lint';
export * from './todos';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Severity = void 0;
var Severity;
(function (Severity) {
Severity[Severity["todo"] = -1] = "todo";
Severity[Severity["off"] = 0] = "off";
Severity[Severity["warn"] = 1] = "warn";
Severity[Severity["error"] = 2] = "error";
})(Severity = exports.Severity || (exports.Severity = {}));
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./lint"), exports);
tslib_1.__exportStar(require("./todos"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@ember-template-lint/todo-utils",
"version": "9.1.2",
"version": "10.0.0-beta.0",
"repository": "https://github.com/ember-template-lint/ember-template-lint-todo-utils.git",

@@ -16,6 +16,7 @@ "license": "MIT",

"prepare": "yarn build",
"test": "jest --no-cache"
"test": "npm-run-all lint test:*",
"test:jest": "jest --no-cache"
},
"dependencies": {
"@types/eslint": "^7.2.12",
"@types/eslint": "^7.2.13",
"fs-extra": "^9.1.0",

@@ -32,3 +33,3 @@ "slash": "^3.0.0",

"date-fns": "^2.22.1",
"eslint": "^7.28.0",
"eslint": "^7.31.0",
"eslint-config-prettier": "^7.2.0",

@@ -43,4 +44,5 @@ "eslint-plugin-jest": "^24.3.6",

"jsdoc-to-markdown": "^6.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.0",
"release-it": "^14.8.0",
"release-it": "^14.10.0",
"release-it-lerna-changelog": "^3.1.0",

@@ -50,3 +52,3 @@ "tmp": "^0.2.1",

"type-fest": "^0.20.2",
"typescript": "^4.2.4"
"typescript": "^4.3.4"
},

@@ -53,0 +55,0 @@ "engines": {

@@ -21,5 +21,5 @@ # @ember-template-lint/todo-utils

<dt><a href="#buildTodoData">buildTodoData(baseDir, lintResults, todoConfig)</a> ⇒</dt>
<dd><p>Adapts a list of <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32">LintResult</a> to a map of <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35">FilePath</a>, <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36">TodoData</a>.</p>
<dd><p>Adapts a list of <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32">LintResult</a> to a map of <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35">TodoFileHash</a>, <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36">TodoData</a>.</p>
</dd>
<dt><a href="#_buildTodoDatum">_buildTodoDatum(lintResult, lintMessage, todoConfig)</a> ⇒</dt>
<dt><a href="#buildTodoDatum">buildTodoDatum(lintResult, lintMessage, todoConfig)</a> ⇒</dt>
<dd><p>Adapts an <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32">LintResult</a> to a <a href="https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36">TodoData</a>. FilePaths are absolute

@@ -32,5 +32,2 @@ when received from a lint result, so they&#39;re converted to relative paths for stability in

</dd>
<dt><a href="#ensureTodoStorageDirSync">ensureTodoStorageDirSync(baseDir)</a> ⇒</dt>
<dd><p>Creates, or ensures the creation of, the .lint-todo directory.</p>
</dd>
<dt><a href="#ensureTodoStorageDir">ensureTodoStorageDir(baseDir)</a> ⇒</dt>

@@ -50,8 +47,2 @@ <dd><p>Creates, or ensures the creation of, the .lint-todo directory.</p>

</dd>
<dt><a href="#writeTodosSync">writeTodosSync(baseDir, lintResults, options)</a> ⇒</dt>
<dd><p>Writes files for todo lint violations. One file is generated for each violation, using a generated
hash to identify each.</p>
<p>Given a list of todo lint violations, this function will also delete existing files that no longer
have a todo lint violation.</p>
</dd>
<dt><a href="#writeTodos">writeTodos(baseDir, lintResults, options)</a> ⇒</dt>

@@ -63,23 +54,11 @@ <dd><p>Writes files for todo lint violations. One file is generated for each violation, using a generated

</dd>
<dt><a href="#readTodosSync">readTodosSync(baseDir)</a> ⇒</dt>
<dd><p>Reads all todo files in the .lint-todo directory.</p>
</dd>
<dt><a href="#readTodos">readTodos(baseDir)</a> ⇒</dt>
<dd><p>Reads all todo files in the .lint-todo directory.</p>
</dd>
<dt><a href="#readTodosForFilePathSync">readTodosForFilePathSync(todoStorageDir, filePath)</a> ⇒</dt>
<dd><p>Reads todo files in the .lint-todo directory for a specific filePath.</p>
</dd>
<dt><a href="#readTodosForFilePath">readTodosForFilePath(todoStorageDir, filePath)</a> ⇒</dt>
<dd><p>Reads todo files in the .lint-todo directory for a specific filePath.</p>
</dd>
<dt><a href="#getTodoBatchesSync">getTodoBatchesSync(lintResults, existing)</a> ⇒</dt>
<dd><p>Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).</p>
</dd>
<dt><a href="#getTodoBatches">getTodoBatches(lintResults, existing)</a> ⇒</dt>
<dd><p>Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).</p>
<dd><p>Gets 4 maps containing todo items to add, remove, those that are expired, or those that are stable (not to be modified).</p>
</dd>
<dt><a href="#applyTodoChangesSync">applyTodoChangesSync(todoStorageDir, add, remove)</a></dt>
<dd><p>Applies todo changes, either adding or removing, based on batches from <code>getTodoBatches</code>.</p>
</dd>
<dt><a href="#applyTodoChanges">applyTodoChanges(todoStorageDir, add, remove)</a></dt>

@@ -116,6 +95,6 @@ <dd><p>Applies todo changes, either adding or removing, based on batches from <code>getTodoBatches</code>.</p>

## buildTodoData(baseDir, lintResults, todoConfig) ⇒
Adapts a list of [LintResult](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32) to a map of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35), [TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
Adapts a list of [LintResult](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32) to a map of [TodoFileHash](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35), [TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
**Kind**: global function
**Returns**: - A Promise resolving to a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
**Returns**: - A Promise resolving to a [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) of [TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).

@@ -128,5 +107,5 @@ | Param | Description |

<a name="_buildTodoDatum"></a>
<a name="buildTodoDatum"></a>
## \_buildTodoDatum(lintResult, lintMessage, todoConfig) ⇒
## buildTodoDatum(lintResult, lintMessage, todoConfig) ⇒
Adapts an [LintResult](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L32) to a [TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36). FilePaths are absolute

@@ -157,14 +136,2 @@ when received from a lint result, so they're converted to relative paths for stability in

<a name="ensureTodoStorageDirSync"></a>
## ensureTodoStorageDirSync(baseDir) ⇒
Creates, or ensures the creation of, the .lint-todo directory.
**Kind**: global function
**Returns**: - The todo storage directory path.
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
<a name="ensureTodoStorageDir"></a>

@@ -176,3 +143,3 @@

**Kind**: global function
**Returns**: - A promise that resolves to the todo storage directory path.
**Returns**: - The todo storage directory path.

@@ -234,20 +201,2 @@ | Param | Description |

<a name="writeTodosSync"></a>
## writeTodosSync(baseDir, lintResults, options) ⇒
Writes files for todo lint violations. One file is generated for each violation, using a generated
hash to identify each.
Given a list of todo lint violations, this function will also delete existing files that no longer
have a todo lint violation.
**Kind**: global function
**Returns**: - The counts of added and removed todos.
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
| lintResults | The raw linting data. |
| options | An object containing write options. |
<a name="writeTodos"></a>

@@ -263,3 +212,3 @@

**Kind**: global function
**Returns**: - A promise that resolves to the counts of added and removed todos.
**Returns**: - The counts of added and removed todos.

@@ -272,14 +221,2 @@ | Param | Description |

<a name="readTodosSync"></a>
## readTodosSync(baseDir) ⇒
Reads all todo files in the .lint-todo directory.
**Kind**: global function
**Returns**: - A [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
<a name="readTodos"></a>

@@ -291,3 +228,3 @@

**Kind**: global function
**Returns**: - A Promise that resolves to a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
**Returns**: - A [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [TodoFilePathHash](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L51)/[TodoMatcher](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/todo-matcher.ts#L4).

@@ -298,15 +235,2 @@ | Param | Description |

<a name="readTodosForFilePathSync"></a>
## readTodosForFilePathSync(todoStorageDir, filePath) ⇒
Reads todo files in the .lint-todo directory for a specific filePath.
**Kind**: global function
**Returns**: - A [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
| Param | Description |
| --- | --- |
| todoStorageDir | The .lint-todo storage directory. |
| filePath | The relative file path of the file to return todo items for. |
<a name="readTodosForFilePath"></a>

@@ -318,3 +242,3 @@

**Kind**: global function
**Returns**: - A Promise that resolves to a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
**Returns**: - A [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [TodoFilePathHash](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L51)/[TodoMatcher](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/todo-matcher.ts#L4).

@@ -326,22 +250,9 @@ | Param | Description |

<a name="getTodoBatchesSync"></a>
## getTodoBatchesSync(lintResults, existing) ⇒
Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
**Kind**: global function
**Returns**: - A [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
| Param | Description |
| --- | --- |
| lintResults | The linting data for all violations. |
| existing | Existing todo lint data. |
<a name="getTodoBatches"></a>
## getTodoBatches(lintResults, existing) ⇒
Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
Gets 4 maps containing todo items to add, remove, those that are expired, or those that are stable (not to be modified).
**Kind**: global function
**Returns**: - A Promise that resolves to a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [FilePath](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).
**Returns**: - A [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) of [TodoFileHash](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L35)/[TodoData](https://github.com/ember-template-lint/ember-template-lint-todo-utils/blob/master/src/types/index.ts#L36).

@@ -353,15 +264,2 @@ | Param | Description |

<a name="applyTodoChangesSync"></a>
## applyTodoChangesSync(todoStorageDir, add, remove)
Applies todo changes, either adding or removing, based on batches from `getTodoBatches`.
**Kind**: global function
| Param | Description |
| --- | --- |
| todoStorageDir | The .lint-todo storage directory. |
| add | Batch of todos to add. |
| remove | Batch of todos to remove. |
<a name="applyTodoChanges"></a>

@@ -368,0 +266,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc