Skip to content

Commit 717db50

Browse files
committed
Normalize linting and formatting with new preset
1 parent 2f37d3e commit 717db50

12 files changed

+93
-145
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/test/fixtures
1+
/test/fixtures
2+
dist/

.eslintrc

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"extends": ["prettier", "prettier/standard"],
5-
"plugins": ["@typescript-eslint"],
2+
"extends": ["kaisermann/typescript"],
63
"env": {
74
"node": true,
85
"jest": true
9-
},
10-
"parserOptions": {
11-
"ecmaVersion": 6,
12-
"sourceType": "module"
136
}
14-
}
7+
}

package-lock.json

+22-72
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,16 @@
4747
"^.+\\.tsx?$": "ts-jest"
4848
}
4949
},
50-
"auto-changelog": {
51-
"ignoreCommitPattern": "chore: release|chore\\(release\\)|Release v\\d"
52-
},
5350
"devDependencies": {
5451
"@types/jest": "^24.0.19",
5552
"@types/node": "^12.7.8",
5653
"@types/stylus": "^0.48.31",
57-
"@typescript-eslint/eslint-plugin": "^2.3.1",
58-
"@typescript-eslint/parser": "^2.3.1",
59-
"auto-changelog": "^1.11.0",
6054
"autoprefixer": "^9.4.7",
6155
"babel-minify": "^0.5.1",
6256
"coffeescript": "^2.3.2",
6357
"conventional-changelog-cli": "^2.0.25",
6458
"eslint": "^5.13.0",
65-
"eslint-config-kaisermann": "^0.0.1",
59+
"eslint-config-kaisermann": "0.0.3",
6660
"jest": "^24.9.0",
6761
"less": "^3.9.0",
6862
"node-sass": "^4.12.0",

src/transformers/stylus.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
23
import stylus from 'stylus';
34

45
import { getIncludePaths } from '../utils';

src/transformers/typescript.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { existsSync } from 'fs';
22
import { dirname, basename, resolve } from 'path';
3+
34
import ts from 'typescript';
45

56
import { Transformer, Options } from '../typings';

src/typings/index.ts

+4-52
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import postcss from 'postcss';
21
import { Processed, Preprocessor } from 'svelte/types/compiler/preprocess';
3-
import { Options as SassOptions } from 'sass';
4-
import { Options as PugOptions } from 'pug';
5-
import { CompilerOptions } from 'typescript';
2+
3+
import * as Options from './options';
4+
5+
export { Options };
66

77
export {
88
Processed,
@@ -30,51 +30,3 @@ export type TransformerOptions<T> =
3030
| boolean
3131
| Record<string, any>
3232
| Transformer<T>;
33-
34-
export namespace Options {
35-
export interface Coffeescript {
36-
inlineMap?: boolean;
37-
filename?: string;
38-
bare?: boolean;
39-
header?: boolean;
40-
transpile?: any;
41-
}
42-
43-
export interface Postcss extends postcss.ProcessOptions {
44-
plugins: postcss.AcceptedPlugin[];
45-
configFilePath?: string;
46-
}
47-
48-
export type Pug = PugOptions;
49-
export type Sass = Omit<SassOptions, 'file'>;
50-
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/less/index.d.ts#L80
51-
export interface Less {
52-
paths?: string[];
53-
plugins?: any[];
54-
strictImports?: boolean;
55-
maxLineLen?: number;
56-
dumpLineNumbers?: 'comment' | string;
57-
silent?: boolean;
58-
strictUnits?: boolean;
59-
globalVars?: Record<string, string>;
60-
modifyVars?: Record<string, string>;
61-
}
62-
63-
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/stylus/index.d.ts#L1410
64-
export interface Stylus {
65-
globals?: Record<string, any>;
66-
functions?: Record<string, any>;
67-
imports?: string[];
68-
paths?: string[];
69-
// custom
70-
sourcemap?: boolean;
71-
}
72-
73-
export interface Typescript {
74-
compilerOptions: CompilerOptions & { transpileOnly?: boolean };
75-
tsconfigFile?: string | boolean;
76-
tsconfigDirectory?: string | boolean;
77-
transpileOnly?: boolean;
78-
reportDiagnostics?: boolean;
79-
}
80-
}

src/typings/options.ts

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import postcss from 'postcss';
2+
import { Options as SassOptions } from 'sass';
3+
import { Options as PugOptions } from 'pug';
4+
import { CompilerOptions } from 'typescript';
5+
6+
export interface Coffeescript {
7+
inlineMap?: boolean;
8+
filename?: string;
9+
bare?: boolean;
10+
header?: boolean;
11+
transpile?: any;
12+
}
13+
14+
export interface Postcss extends postcss.ProcessOptions {
15+
plugins: postcss.AcceptedPlugin[];
16+
configFilePath?: string;
17+
}
18+
19+
export type Pug = PugOptions;
20+
export type Sass = Omit<SassOptions, 'file'>;
21+
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/less/index.d.ts#L80
22+
export interface Less {
23+
paths?: string[];
24+
plugins?: any[];
25+
strictImports?: boolean;
26+
maxLineLen?: number;
27+
dumpLineNumbers?: 'comment' | string;
28+
silent?: boolean;
29+
strictUnits?: boolean;
30+
globalVars?: Record<string, string>;
31+
modifyVars?: Record<string, string>;
32+
}
33+
34+
// from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/stylus/index.d.ts#L1410
35+
export interface Stylus {
36+
globals?: Record<string, any>;
37+
functions?: Record<string, any>;
38+
imports?: string[];
39+
paths?: string[];
40+
// custom
41+
sourcemap?: boolean;
42+
}
43+
44+
export interface Typescript {
45+
compilerOptions: CompilerOptions & { transpileOnly?: boolean };
46+
tsconfigFile?: string | boolean;
47+
tsconfigDirectory?: string | boolean;
48+
transpileOnly?: boolean;
49+
reportDiagnostics?: boolean;
50+
}

src/utils.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { readFile, access } from 'fs';
22
import { resolve, dirname, basename } from 'path';
3-
import { PreprocessorArgs } from './typings';
43

5-
import { Transformer, TransformerArgs, TransformerOptions } from './typings';
4+
import {
5+
PreprocessorArgs,
6+
Transformer,
7+
TransformerArgs,
8+
TransformerOptions,
9+
} from './typings';
610

711
const LANG_DICT = new Map([
812
['pcss', 'css'],

test/processors.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
typescript,
99
pug,
1010
} from '../src';
11+
1112
import { CSS_PATTERN, getFixtureContent, preprocess } from './utils';
1213

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

55-
MARKUP_LANGS.forEach(([lang, ext, processor, options]) => {
56+
MARKUP_LANGS.forEach(([lang, _, processor, options]) => {
5657
const EXPECTED_TEMPLATE = getFixtureContent('template.html');
5758
describe(`processor - ${lang}`, () => {
5859
it('should preprocess the whole file', async () => {

0 commit comments

Comments
 (0)