UNPKG

@vidavidorra/create-project

Version:
40 lines 1.75 kB
import ts from 'typescript'; import { File } from './file.js'; class LintStaged extends File { constructor(path, options) { super(path, { ...options, format: true }); } process() { this._content = ts.createPrinter().printFile(this.sourceFile()); return this; } xo() { return ts.factory.createStringLiteral('xo --fix'); } ava() { return ts.factory.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.factory.createStringLiteral('ava')); } prettier() { return ts.factory.createStringLiteral('prettier --write'); } config() { return ts.factory.createObjectLiteralExpression([ ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('*.{ts,tsx,js,jsx}'), ts.factory.createArrayLiteralExpression([ this.xo(), ...(this._options.testing ? [this.ava()] : []), ])), ts.factory.createPropertyAssignment(ts.factory.createStringLiteral('*.{vue,css,less,scss,html,htm,json,md,markdown,yml,yaml}'), this.prettier()), ]); } sourceFile() { const statements = [ ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.factory.createIdentifier('config'), undefined, undefined, this.config()), ], ts.NodeFlags.Const)), ts.factory.createExportAssignment(undefined, undefined, ts.factory.createIdentifier('config')), ]; return ts.factory.createSourceFile(statements, ts.factory.createToken(ts.SyntaxKind.EndOfFileToken), ts.NodeFlags.None); } } export { LintStaged }; //# sourceMappingURL=lint-staged.js.map