Skip to content

Commit

Permalink
Normalize linting and formatting with new preset
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Nov 5, 2019
1 parent 2f37d3e commit 717db50
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 145 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/test/fixtures
/test/fixtures
dist/
11 changes: 2 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"extends": ["prettier", "prettier/standard"],
"plugins": ["@typescript-eslint"],
"extends": ["kaisermann/typescript"],
"env": {
"node": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
}
}
}
94 changes: 22 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,16 @@
"^.+\\.tsx?$": "ts-jest"
}
},
"auto-changelog": {
"ignoreCommitPattern": "chore: release|chore\\(release\\)|Release v\\d"
},
"devDependencies": {
"@types/jest": "^24.0.19",
"@types/node": "^12.7.8",
"@types/stylus": "^0.48.31",
"@typescript-eslint/eslint-plugin": "^2.3.1",
"@typescript-eslint/parser": "^2.3.1",
"auto-changelog": "^1.11.0",
"autoprefixer": "^9.4.7",
"babel-minify": "^0.5.1",
"coffeescript": "^2.3.2",
"conventional-changelog-cli": "^2.0.25",
"eslint": "^5.13.0",
"eslint-config-kaisermann": "^0.0.1",
"eslint-config-kaisermann": "0.0.3",
"jest": "^24.9.0",
"less": "^3.9.0",
"node-sass": "^4.12.0",
Expand Down
1 change: 1 addition & 0 deletions src/transformers/stylus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';

import stylus from 'stylus';

import { getIncludePaths } from '../utils';
Expand Down
1 change: 1 addition & 0 deletions src/transformers/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync } from 'fs';
import { dirname, basename, resolve } from 'path';

import ts from 'typescript';

import { Transformer, Options } from '../typings';
Expand Down
56 changes: 4 additions & 52 deletions src/typings/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import postcss from 'postcss';
import { Processed, Preprocessor } from 'svelte/types/compiler/preprocess';
import { Options as SassOptions } from 'sass';
import { Options as PugOptions } from 'pug';
import { CompilerOptions } from 'typescript';

import * as Options from './options';

export { Options };

export {
Processed,
Expand Down Expand Up @@ -30,51 +30,3 @@ export type TransformerOptions<T> =
| boolean
| Record<string, any>
| Transformer<T>;

export namespace Options {
export interface Coffeescript {
inlineMap?: boolean;
filename?: string;
bare?: boolean;
header?: boolean;
transpile?: any;
}

export interface Postcss extends postcss.ProcessOptions {
plugins: postcss.AcceptedPlugin[];
configFilePath?: string;
}

export type Pug = PugOptions;
export type Sass = Omit<SassOptions, 'file'>;
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/less/index.d.ts#L80
export interface Less {
paths?: string[];
plugins?: any[];
strictImports?: boolean;
maxLineLen?: number;
dumpLineNumbers?: 'comment' | string;
silent?: boolean;
strictUnits?: boolean;
globalVars?: Record<string, string>;
modifyVars?: Record<string, string>;
}

// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/stylus/index.d.ts#L1410
export interface Stylus {
globals?: Record<string, any>;
functions?: Record<string, any>;
imports?: string[];
paths?: string[];
// custom
sourcemap?: boolean;
}

export interface Typescript {
compilerOptions: CompilerOptions & { transpileOnly?: boolean };
tsconfigFile?: string | boolean;
tsconfigDirectory?: string | boolean;
transpileOnly?: boolean;
reportDiagnostics?: boolean;
}
}
50 changes: 50 additions & 0 deletions src/typings/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import postcss from 'postcss';
import { Options as SassOptions } from 'sass';
import { Options as PugOptions } from 'pug';
import { CompilerOptions } from 'typescript';

export interface Coffeescript {
inlineMap?: boolean;
filename?: string;
bare?: boolean;
header?: boolean;
transpile?: any;
}

export interface Postcss extends postcss.ProcessOptions {
plugins: postcss.AcceptedPlugin[];
configFilePath?: string;
}

export type Pug = PugOptions;
export type Sass = Omit<SassOptions, 'file'>;
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/less/index.d.ts#L80
export interface Less {
paths?: string[];
plugins?: any[];
strictImports?: boolean;
maxLineLen?: number;
dumpLineNumbers?: 'comment' | string;
silent?: boolean;
strictUnits?: boolean;
globalVars?: Record<string, string>;
modifyVars?: Record<string, string>;
}

// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/stylus/index.d.ts#L1410
export interface Stylus {
globals?: Record<string, any>;
functions?: Record<string, any>;
imports?: string[];
paths?: string[];
// custom
sourcemap?: boolean;
}

export interface Typescript {
compilerOptions: CompilerOptions & { transpileOnly?: boolean };
tsconfigFile?: string | boolean;
tsconfigDirectory?: string | boolean;
transpileOnly?: boolean;
reportDiagnostics?: boolean;
}
8 changes: 6 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { readFile, access } from 'fs';
import { resolve, dirname, basename } from 'path';
import { PreprocessorArgs } from './typings';

import { Transformer, TransformerArgs, TransformerOptions } from './typings';
import {
PreprocessorArgs,
Transformer,
TransformerArgs,
TransformerOptions,
} from './typings';

const LANG_DICT = new Map([
['pcss', 'css'],
Expand Down
3 changes: 2 additions & 1 deletion test/processors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
typescript,
pug,
} from '../src';

import { CSS_PATTERN, getFixtureContent, preprocess } from './utils';

const EXPECTED_SCRIPT = getFixtureContent('script.js');
Expand Down Expand Up @@ -52,7 +53,7 @@ SCRIPT_LANGS.forEach(([lang, ext, processor, options]) => {
});
});

MARKUP_LANGS.forEach(([lang, ext, processor, options]) => {
MARKUP_LANGS.forEach(([lang, _, processor, options]) => {
const EXPECTED_TEMPLATE = getFixtureContent('template.html');
describe(`processor - ${lang}`, () => {
it('should preprocess the whole file', async () => {
Expand Down
Loading

0 comments on commit 717db50

Please sign in to comment.