mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 15:00:26 +00:00
feat(eslint-plugin-prettier): initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import * as utils from 'eslint-plugin-prettier';
|
||||
|
||||
declare function log(...args: Array<string | number>): void;
|
||||
|
||||
utils.showInvisibles(' some string ');
|
||||
|
||||
utils.generateDifferences('abc', 'def').forEach(difference => {
|
||||
const {
|
||||
operation,
|
||||
offset,
|
||||
deleteText = '',
|
||||
insertText = '',
|
||||
} = difference;
|
||||
|
||||
switch (operation) {
|
||||
case utils.DifferenceOperation.Delete:
|
||||
log('delete', offset, deleteText);
|
||||
break;
|
||||
case utils.DifferenceOperation.Insert:
|
||||
log('insert', offset, insertText);
|
||||
break;
|
||||
case utils.DifferenceOperation.Replace:
|
||||
log('replace', offset, insertText, deleteText);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected operation: '${operation}'`);
|
||||
}
|
||||
});
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// Type definitions for eslint-plugin-prettier 2.2
|
||||
// Project: https://github.com/prettier/eslint-plugin-prettier
|
||||
// Definitions by: Ika <https://github.com/ikatyang>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/**
|
||||
* Converts invisible characters to a commonly recognizable visible form.
|
||||
* @param str The string with invisibles to convert.
|
||||
*/
|
||||
export function showInvisibles(str: string): string;
|
||||
|
||||
/**
|
||||
* Generate results for differences between source code and formatted version.
|
||||
* @param source The original source.
|
||||
* @param formatted The formatted source.
|
||||
*/
|
||||
export function generateDifferences(
|
||||
source: string,
|
||||
formatted: string,
|
||||
): Difference[];
|
||||
|
||||
export interface Difference {
|
||||
operation: DifferenceOperation;
|
||||
offset: number;
|
||||
insertText?: string;
|
||||
deleteText?: string;
|
||||
}
|
||||
|
||||
export const enum DifferenceOperation {
|
||||
Insert = 'insert',
|
||||
Delete = 'delete',
|
||||
Replace = 'replace',
|
||||
}
|
||||
|
||||
export const rules: any;
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "eslint-plugin-prettier-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user