Merge pull request #19009 from ikatyang/add-eslint-plugin-prettier-definitions

feat(eslint-plugin-prettier): initial commit
This commit is contained in:
Daniel Rosenwasser
2017-08-19 09:08:04 -07:00
committed by GitHub
4 changed files with 73 additions and 0 deletions
@@ -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 'delete':
log('delete', offset, deleteText);
break;
case 'insert':
log('insert', offset, insertText);
break;
case 'replace':
log('replace', offset, insertText, deleteText);
break;
default:
throw new Error(`Unexpected operation: '${operation}'`);
}
});
+29
View File
@@ -0,0 +1,29 @@
// 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
/**
* 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: 'insert' | 'delete' | 'replace';
offset: number;
insertText?: string;
deleteText?: string;
}
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"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }