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 3.1.0 to 3.2.0

17

CHANGELOG.md

@@ -0,1 +1,18 @@

## v3.2.0 (2020-12-22)
#### :rocket: Enhancement
* [#34](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/34) Auto-generating API docs ([@scalvert](https://github.com/scalvert))
* [#33](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/33) Implements todo-due-dates spec ([@scalvert](https://github.com/scalvert))
#### :memo: Documentation
* [#36](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/36) Adding eslint-plugin-tsdoc and regenerating docs ([@scalvert](https://github.com/scalvert))
* [#34](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/34) Auto-generating API docs ([@scalvert](https://github.com/scalvert))
#### :house: Internal
* [#35](https://github.com/ember-template-lint/ember-template-lint-todo-utils/pull/35) Updating test fixtures to not suck ([@scalvert](https://github.com/scalvert))
#### Committers: 1
- Steve Calvert ([@scalvert](https://github.com/scalvert))
## v3.1.0 (2020-12-17)

@@ -2,0 +19,0 @@

23

lib/builders.d.ts

@@ -1,19 +0,22 @@

import { FilePath, LintMessage, LintResult, TodoData } from './types';
import { DaysToDecay, FilePath, LintMessage, LintResult, TodoData } from './types';
/**
* Adapts a list of {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/160f43ae6852c4eefec2641e54cff96dd7b63488/types/eslint/index.d.ts#L640 ESLint.LintResult}
* or {@link TemplateLintResult} to a map of {@link FilePath}, {@link TodoData}.
* Adapts a list of {@link LintResult} to a map of {@link FilePath}, {@link TodoData}.
*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param lintResults A list of {LintResult} objects to convert to {TodoData} objects.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param lintResults - A list of {@link LintResult} objects to convert to {@link TodoData} objects.
* @param daysToDecay - An object containing the warn or error days, in integers.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/
export declare function buildTodoData(baseDir: string, lintResults: LintResult[]): Map<FilePath, TodoData>;
export declare function buildTodoData(baseDir: string, lintResults: LintResult[], daysToDecay?: DaysToDecay): Map<FilePath, TodoData>;
/**
* Adapts an {ESLint.LintResult} or {TemplateLintResult} to a {TodoData}. FilePaths are absolute
* Adapts an {@link LintResult} to a {@link TodoData}. FilePaths are absolute
* when received from a lint result, so they're converted to relative paths for stability in
* serializing the contents to disc.
*
* @param lintResult The lint result object, either an {ESLint.LintResult} or a {TemplateLintResult}.
* @param lintMessage A lint message object representing a specific violation for a file.
* @param lintResult - The lint result object.
* @param lintMessage - A lint message object representing a specific violation for a file.
* @param daysToDecay - An object containing the warn or error days, in integers.
* @returns - A {@link TodoData} object.
*/
export declare function _buildTodoDatum(baseDir: string, lintResult: LintResult, lintMessage: LintMessage): TodoData;
export declare function _buildTodoDatum(baseDir: string, lintResult: LintResult, lintMessage: LintMessage, daysToDecay?: DaysToDecay): TodoData;
//# sourceMappingURL=builders.d.ts.map

@@ -8,9 +8,10 @@ "use strict";

/**
* Adapts a list of {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/160f43ae6852c4eefec2641e54cff96dd7b63488/types/eslint/index.d.ts#L640 ESLint.LintResult}
* or {@link TemplateLintResult} to a map of {@link FilePath}, {@link TodoData}.
* Adapts a list of {@link LintResult} to a map of {@link FilePath}, {@link TodoData}.
*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param lintResults A list of {LintResult} objects to convert to {TodoData} objects.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param lintResults - A list of {@link LintResult} objects to convert to {@link TodoData} objects.
* @param daysToDecay - An object containing the warn or error days, in integers.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/
function buildTodoData(baseDir, lintResults) {
function buildTodoData(baseDir, lintResults, daysToDecay) {
const results = lintResults.filter((result) => result.messages.length > 0);

@@ -20,3 +21,3 @@ const todoData = results.reduce((converted, lintResult) => {

if (message.severity === 2) {
const todoDatum = _buildTodoDatum(baseDir, lintResult, message);
const todoDatum = _buildTodoDatum(baseDir, lintResult, message, daysToDecay);
converted.set(io_1.todoFilePathFor(todoDatum), todoDatum);

@@ -31,16 +32,16 @@ }

/**
* Adapts an {ESLint.LintResult} or {TemplateLintResult} to a {TodoData}. FilePaths are absolute
* Adapts an {@link LintResult} to a {@link TodoData}. FilePaths are absolute
* when received from a lint result, so they're converted to relative paths for stability in
* serializing the contents to disc.
*
* @param lintResult The lint result object, either an {ESLint.LintResult} or a {TemplateLintResult}.
* @param lintMessage A lint message object representing a specific violation for a file.
* @param lintResult - The lint result object.
* @param lintMessage - A lint message object representing a specific violation for a file.
* @param daysToDecay - An object containing the warn or error days, in integers.
* @returns - A {@link TodoData} object.
*/
function _buildTodoDatum(baseDir, lintResult, lintMessage) {
/**
* Note: If https://github.com/nodejs/node/issues/13683 is fixed, remove slash() and use posix.relative
* provided that the fix is landed on the supported node versions of this lib
*/
function _buildTodoDatum(baseDir, lintResult, lintMessage, daysToDecay) {
// Note: If https://github.com/nodejs/node/issues/13683 is fixed, remove slash() and use posix.relative
// provided that the fix is landed on the supported node versions of this lib
const filePath = path_1.isAbsolute(lintResult.filePath) ? path_1.relative(baseDir, lintResult.filePath) : lintResult.filePath;
return {
const todoDatum = {
engine: getEngine(lintResult),

@@ -51,4 +52,11 @@ filePath: slash(filePath),

column: lintMessage.column,
createdDate: Date.now(),
createdDate: new Date(),
};
if (daysToDecay === null || daysToDecay === void 0 ? void 0 : daysToDecay.warn) {
todoDatum.warnDate = addDays(todoDatum.createdDate, daysToDecay.warn);
}
if (daysToDecay === null || daysToDecay === void 0 ? void 0 : daysToDecay.error) {
todoDatum.errorDate = addDays(todoDatum.createdDate, daysToDecay.error);
}
return todoDatum;
}

@@ -68,2 +76,7 @@ exports._buildTodoDatum = _buildTodoDatum;

}
function addDays(createdDate, days) {
const datePlusDays = new Date(createdDate.valueOf());
datePlusDays.setDate(datePlusDays.getDate() + days);
return datePlusDays;
}
//# sourceMappingURL=builders.js.map

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

import { FilePath, LintResult, TodoData } from './types';
import { DaysToDecay, FilePath, LintResult, TodoData } from './types';
/**
* Determines if the .lint-todo storage directory exists.
*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - true if the todo storage directory exists, otherwise false.
*/

@@ -11,7 +12,9 @@ export declare function todoStorageDirExists(baseDir: string): boolean;

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - 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.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - The todo storage directory path.
*/

@@ -25,4 +28,5 @@ export declare function getTodoStorageDirPath(baseDir: string): string;

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param todoData The linting data for an individual violation.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param todoData - The linting data for an individual violation.
* @returns - The todo file path for a {@link TodoData} object.
*/

@@ -33,3 +37,4 @@ export declare function todoFilePathFor(todoData: TodoData): string;

*
* @param filePath The filePath from linting data for an individual violation.
* @param filePath - The filePath from linting data for an individual violation.
* @returns - The todo directory for a specific filepath.
*/

@@ -40,3 +45,4 @@ export declare function todoDirFor(filePath: string): string;

*
* @param todoData The linting data for an individual violation.
* @param todoData - The linting data for an individual violation.
* @returns - The todo file name for a {@link TodoData} object.
*/

@@ -51,11 +57,14 @@ export declare function todoFileNameFor(todoData: TodoData): string;

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param lintResults The raw linting data.
* @param filePath? The relative file path of the file to update violations for.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param lintResults - The raw linting data.
* @param filePath - The relative file path of the file to update violations for.
* @param daysToDecay - An object containing the warn or error days, in integers.
* @returns - The todo storage directory path.
*/
export declare function writeTodos(baseDir: string, lintResults: LintResult[], filePath?: string): Promise<string>;
export declare function writeTodos(baseDir: string, lintResults: LintResult[], filePath?: string, daysToDecay?: DaysToDecay): Promise<string>;
/**
* Reads all todo files in the .lint-todo directory.
*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/

@@ -66,4 +75,5 @@ export declare function readTodos(baseDir: string): Promise<Map<FilePath, TodoData>>;

*
* @param todoStorageDir The .lint-todo storage directory.
* @param filePath The relative file path of the file to return todo items for.
* @param todoStorageDir - The .lint-todo storage directory.
* @param filePath - The relative file path of the file to return todo items for.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/

@@ -74,4 +84,5 @@ export declare function readTodosForFilePath(baseDir: string, filePath: string): Promise<Map<FilePath, TodoData>>;

*
* @param lintResults The linting data for all violations.
* @param existing Existing todo lint data.
* @param lintResults - The linting data for all violations.
* @param existing - Existing todo lint data.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/

@@ -82,7 +93,7 @@ export declare function getTodoBatches(lintResults: Map<FilePath, TodoData>, existing: Map<FilePath, TodoData>): Promise<Map<FilePath, TodoData>[]>;

*
* @param todoStorageDir The .lint-todo storage directory.
* @param add Batch of todos to add.
* @param remove Batch of todos to remove.
* @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>;
//# sourceMappingURL=io.d.ts.map

@@ -11,3 +11,4 @@ "use strict";

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - true if the todo storage directory exists, otherwise false.
*/

@@ -21,3 +22,4 @@ function todoStorageDirExists(baseDir) {

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - The todo storage directory path.
*/

@@ -31,3 +33,4 @@ async function ensureTodoStorageDir(baseDir) {

/**
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - The todo storage directory path.
*/

@@ -44,4 +47,5 @@ function getTodoStorageDirPath(baseDir) {

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param todoData The linting data for an individual violation.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param todoData - The linting data for an individual violation.
* @returns - The todo file path for a {@link TodoData} object.
*/

@@ -55,3 +59,4 @@ function todoFilePathFor(todoData) {

*
* @param filePath The filePath from linting data for an individual violation.
* @param filePath - The filePath from linting data for an individual violation.
* @returns - The todo directory for a specific filepath.
*/

@@ -65,3 +70,4 @@ function todoDirFor(filePath) {

*
* @param todoData The linting data for an individual violation.
* @param todoData - The linting data for an individual violation.
* @returns - The todo file name for a {@link TodoData} object.
*/

@@ -80,7 +86,9 @@ function todoFileNameFor(todoData) {

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param lintResults The raw linting data.
* @param filePath? The relative file path of the file to update violations for.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @param lintResults - The raw linting data.
* @param filePath - The relative file path of the file to update violations for.
* @param daysToDecay - An object containing the warn or error days, in integers.
* @returns - The todo storage directory path.
*/
async function writeTodos(baseDir, lintResults, filePath) {
async function writeTodos(baseDir, lintResults, filePath = '', daysToDecay) {
const todoStorageDir = await ensureTodoStorageDir(baseDir);

@@ -90,3 +98,3 @@ const existing = filePath

: await readTodos(baseDir);
const [add, remove] = await getTodoBatches(builders_1.buildTodoData(baseDir, lintResults), existing);
const [add, remove] = await getTodoBatches(builders_1.buildTodoData(baseDir, lintResults, daysToDecay), existing);
await applyTodoChanges(todoStorageDir, add, remove);

@@ -99,3 +107,4 @@ return todoStorageDir;

*
* @param baseDir The base directory that contains the .lint-todo storage directory.
* @param baseDir - The base directory that contains the .lint-todo storage directory.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/

@@ -119,4 +128,5 @@ async function readTodos(baseDir) {

*
* @param todoStorageDir The .lint-todo storage directory.
* @param filePath The relative file path of the file to return todo items for.
* @param todoStorageDir - The .lint-todo storage directory.
* @param filePath - The relative file path of the file to return todo items for.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/

@@ -147,4 +157,5 @@ async function readTodosForFilePath(baseDir, filePath) {

*
* @param lintResults The linting data for all violations.
* @param existing Existing todo lint data.
* @param lintResults - The linting data for all violations.
* @param existing - Existing todo lint data.
* @returns - A Promise resolving to a {@link Map} of {@link FilePath}/{@link TodoData}.
*/

@@ -177,5 +188,5 @@ async function getTodoBatches(lintResults, existing) {

*
* @param todoStorageDir The .lint-todo storage directory.
* @param add Batch of todos to add.
* @param remove Batch of todos to remove.
* @param todoStorageDir - The .lint-todo storage directory.
* @param add - Batch of todos to add.
* @param remove - Batch of todos to remove.
*/

@@ -182,0 +193,0 @@ async function applyTodoChanges(todoStorageDir, add, remove) {

@@ -31,6 +31,11 @@ import { ESLint, Linter } from 'eslint';

column: number;
createdDate: number;
dueDate?: Date;
createdDate: Date;
warnDate?: Date;
errorDate?: Date;
}
export interface DaysToDecay {
warn?: number;
error?: number;
}
export {};
//# sourceMappingURL=index.d.ts.map
{
"name": "@ember-template-lint/todo-utils",
"version": "3.1.0",
"version": "3.2.0",
"repository": "https://github.com/ember-template-lint/ember-template-lint-todo-utils.git",

@@ -13,2 +13,3 @@ "license": "MIT",

"clean": "tsc --build --clean",
"docs:update": "yarn build && node scripts/generate-api-docs.js",
"lint": "eslint . --ext .ts",

@@ -29,2 +30,3 @@ "prepare": "yarn build",

"@typescript-eslint/parser": "^4.2.0",
"date-fns": "^2.16.1",
"eslint": "^7.9.0",

@@ -35,4 +37,6 @@ "eslint-config-prettier": "^6.11.0",

"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-tsdoc": "^0.2.10",
"eslint-plugin-unicorn": "^22.0.0",
"jest": "^26.4.2",
"jsdoc-to-markdown": "^6.0.1",
"prettier": "^2.1.2",

@@ -39,0 +43,0 @@ "release-it": "^13.6.5",

@@ -14,22 +14,33 @@ # @ember-template-lint/todo-utils

<!--DOCS_START-->
## Functions
<dl>
<dt><a href="#buildTodoData">buildTodoData(lintResults)</a></dt>
<dd><p>Adapts a list of <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/160f43ae6852c4eefec2641e54cff96dd7b63488/types/eslint/index.d.ts#L640">ESLint.LintResult</a>
or <a href="TemplateLintResult">TemplateLintResult</a> to a map of <a href="FilePath">FilePath</a>, <a href="TodoData">TodoData</a>.</p>
<dt><a href="#buildTodoData">buildTodoData(baseDir, lintResults, daysToDecay)</a> ⇒</dt>
<dd><p>Adapts a list of <a href="LintResult">LintResult</a> to a map of <a href="FilePath">FilePath</a>, <a href="TodoData">TodoData</a>.</p>
</dd>
<dt><a href="#ensureTodoDir">ensureTodoDir(baseDir)</a></dt>
<dt><a href="#_buildTodoDatum">_buildTodoDatum(lintResult, lintMessage, daysToDecay)</a> ⇒</dt>
<dd><p>Adapts an <a href="LintResult">LintResult</a> to a <a href="TodoData">TodoData</a>. FilePaths are absolute
when received from a lint result, so they&#39;re converted to relative paths for stability in
serializing the contents to disc.</p>
</dd>
<dt><a href="#todoStorageDirExists">todoStorageDirExists(baseDir)</a> ⇒</dt>
<dd><p>Determines if the .lint-todo storage directory exists.</p>
</dd>
<dt><a href="#ensureTodoStorageDir">ensureTodoStorageDir(baseDir)</a> ⇒</dt>
<dd><p>Creates, or ensures the creation of, the .lint-todo directory.</p>
</dd>
<dt><a href="#getTodoStorageDirPath">getTodoStorageDirPath(baseDir)</a></dt>
<dt><a href="#getTodoStorageDirPath">getTodoStorageDirPath(baseDir)</a> ⇒</dt>
<dd></dd>
<dt><a href="#todoFilePathFor">todoFilePathFor(todoData)</a></dt>
<dt><a href="#todoFilePathFor">todoFilePathFor(baseDir, todoData)</a> ⇒</dt>
<dd><p>Creates a file path from the linting data. Excludes extension.</p>
</dd>
<dt><a href="#todoDirFor">todoDirFor(filePath)</a></dt>
<dt><a href="#todoDirFor">todoDirFor(filePath)</a> ⇒</dt>
<dd><p>Creates a short hash for the todo&#39;s file path.</p>
</dd>
<dt><a href="#todoFileNameFor">todoFileNameFor(todoData)</a></dt>
<dt><a href="#todoFileNameFor">todoFileNameFor(todoData)</a> ⇒</dt>
<dd><p>Generates a unique filename for a todo lint data.</p>
</dd>
<dt><a href="#writeTodos">writeTodos(baseDir, lintResults, filePath?)</a></dt>
<dt><a href="#writeTodos">writeTodos(baseDir, lintResults, filePath, daysToDecay)</a> ⇒</dt>
<dd><p>Writes files for todo lint violations. One file is generated for each violation, using a generated

@@ -40,10 +51,13 @@ hash to identify each.</p>

</dd>
<dt><a href="#readTodos">readTodos(todoStorageDir, filePath?)</a></dt>
<dt><a href="#readTodos">readTodos(baseDir)</a> ⇒</dt>
<dd><p>Reads all todo files in the .lint-todo directory.</p>
</dd>
<dt><a href="#getTodoBatches">getTodoBatches(lintResults, existing)</a></dt>
<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="#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>
<dt><a href="#applyTodoChanges">applyTodoChanges(todoStorageDir, add, remove)</a></dt>
<dd><p>Applies todo changes, either adding or removing, based on batches from `getTodoBatches`.</p>
<dd><p>Applies todo changes, either adding or removing, based on batches from <code>getTodoBatches</code>.</p>
</dd>

@@ -54,23 +68,52 @@ </dl>

## buildTodoData(lintResults)
## buildTodoData(baseDir, lintResults, daysToDecay) ⇒
Adapts a list of [LintResult](LintResult) to a map of [FilePath](FilePath), [TodoData](TodoData).
Adapts a list of [ESLint.LintResult](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/160f43ae6852c4eefec2641e54cff96dd7b63488/types/eslint/index.d.ts#L640)
or [TemplateLintResult](TemplateLintResult) to a map of [FilePath](FilePath), [TodoData](TodoData).
**Kind**: global function
**Returns**: - A Promise resolving to a [Map](Map) of [FilePath](FilePath)/[TodoData](TodoData).
**Kind**: global function
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
| lintResults | A list of [LintResult](LintResult) objects to convert to [TodoData](TodoData) objects. |
| daysToDecay | An object containing the warn or error days, in integers. |
| Param | Type | Description |
| ----------- | ----------------------- | --------------------------------------------------- |
| lintResults | <code>LintResult</code> | A list of objects to convert to {TodoData} objects. |
<a name="_buildTodoDatum"></a>
<a name="ensureTodoDir"></a>
## \_buildTodoDatum(lintResult, lintMessage, daysToDecay) ⇒
Adapts an [LintResult](LintResult) to a [TodoData](TodoData). FilePaths are absolute
when received from a lint result, so they're converted to relative paths for stability in
serializing the contents to disc.
## ensureTodoDir(baseDir)
**Kind**: global function
**Returns**: - A [TodoData](TodoData) object.
| Param | Description |
| --- | --- |
| lintResult | The lint result object. |
| lintMessage | A lint message object representing a specific violation for a file. |
| daysToDecay | An object containing the warn or error days, in integers. |
<a name="todoStorageDirExists"></a>
## todoStorageDirExists(baseDir) ⇒
Determines if the .lint-todo storage directory exists.
**Kind**: global function
**Returns**: - true if the todo storage directory exists, otherwise false.
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
<a name="ensureTodoStorageDir"></a>
## ensureTodoStorageDir(baseDir) ⇒
Creates, or ensures the creation of, the .lint-todo directory.
**Kind**: global function
**Kind**: global function
**Returns**: - The todo storage directory path.
| Param | Description |
| ------- | ------------------------------------------------------------------ |
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |

@@ -80,8 +123,8 @@

## getTodoStorageDirPath(baseDir)
## getTodoStorageDirPath(baseDir) ⇒
**Kind**: global function
**Returns**: - The todo storage directory path.
**Kind**: global function
| Param | Description |
| ------- | ------------------------------------------------------------------ |
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |

@@ -91,28 +134,27 @@

## todoFilePathFor(todoData)
## todoFilePathFor(baseDir, todoData) ⇒
Creates a file path from the linting data. Excludes extension.
**Kind**: global function
**Kind**: global function
**Returns**: - The todo file path for a [TodoData](TodoData) object.
| Param | Description |
| -------- | --------------------------------------------- |
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
| todoData | The linting data for an individual violation. |
**Example**
**Example**
```js
42b8532cff6da75c5e5895a6f33522bf37418d0c/6e3be839
```
<a name="todoDirFor"></a>
## todoDirFor(filePath)
## todoDirFor(filePath) ⇒
Creates a short hash for the todo's file path.
**Kind**: global function
**Kind**: global function
**Returns**: - The todo directory for a specific filepath.
| Param | Description |
| -------- | ----------------------------------------------------------- |
| Param | Description |
| --- | --- |
| filePath | The filePath from linting data for an individual violation. |

@@ -122,10 +164,10 @@

## todoFileNameFor(todoData)
## todoFileNameFor(todoData) ⇒
Generates a unique filename for a todo lint data.
**Kind**: global function
**Kind**: global function
**Returns**: - The todo file name for a [TodoData](TodoData) object.
| Param | Description |
| -------- | --------------------------------------------- |
| Param | Description |
| --- | --- |
| todoData | The linting data for an individual violation. |

@@ -135,4 +177,3 @@

## writeTodos(baseDir, lintResults, filePath?)
## writeTodos(baseDir, lintResults, filePath, daysToDecay) ⇒
Writes files for todo lint violations. One file is generated for each violation, using a generated

@@ -144,34 +185,64 @@ hash to identify each.

**Kind**: global function
**Kind**: global function
**Returns**: - The todo storage directory path.
| Param | Description |
| ----------- | ------------------------------------------------------------------ |
| baseDir | The base directory that contains the .lint-todo storage directory. |
| lintResults | The raw linting data. |
| filePath? | The absolute file path of the file to update violations for. |
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
| lintResults | The raw linting data. |
| filePath | The relative file path of the file to update violations for. |
| daysToDecay | An object containing the warn or error days, in integers. |
<a name="readTodos"></a>
## readTodos(todoStorageDir, filePath?)
## readTodos(baseDir) ⇒
Reads all todo files in the .lint-todo directory.
**Kind**: global function
**Kind**: global function
**Returns**: - A Promise resolving to a [Map](Map) of [FilePath](FilePath)/[TodoData](TodoData).
| Param | Description |
| -------------- | ------------------------------------------------------------ |
| todoStorageDir | The .lint-todo storage directory. |
| filePath? | The absolute file path of the file to return todo items for. |
| Param | Description |
| --- | --- |
| baseDir | The base directory that contains the .lint-todo storage directory. |
<a name="readTodosForFilePath"></a>
## readTodosForFilePath(todoStorageDir, filePath) ⇒
Reads todo files in the .lint-todo directory for a specific filePath.
**Kind**: global function
**Returns**: - A Promise resolving to a [Map](Map) of [FilePath](FilePath)/[TodoData](TodoData).
| Param | Description |
| --- | --- |
| todoStorageDir | The .lint-todo storage directory. |
| filePath | The relative file path of the file to return todo items for. |
<a name="getTodoBatches"></a>
## getTodoBatches(lintResults, existing)
## getTodoBatches(lintResults, existing) ⇒
Gets 3 maps containing todo items to add, remove, or those that are stable (not to be modified).
**Kind**: global function
**Kind**: global function
**Returns**: - A Promise resolving to a [Map](Map) of [FilePath](FilePath)/[TodoData](TodoData).
| Param | Description |
| ----------- | ------------------------------------ |
| Param | Description |
| --- | --- |
| lintResults | The linting data for all violations. |
| existing | Existing todo lint data. |
| existing | Existing todo lint data. |
<a name="applyTodoChanges"></a>
## applyTodoChanges(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. |
<!--DOCS_END-->

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