Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to typescript #206

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# https://eslint.org/docs/rules/

root: true
parser: '@typescript-eslint/parser'
parserOptions:
sourceType: script
sourceType: module
ecmaVersion: 2018
env:
es6: true
node: true
plugins:
- prettier
- import
- '@typescript-eslint'
ignorePatterns:
- lib

extends:
- eslint:recommended
- plugin:import/recommended
- plugin:prettier/recommended
- plugin:@typescript-eslint/eslint-recommended

rules:
# Prettier
prettier/prettier:
Expand Down Expand Up @@ -118,7 +123,7 @@ rules:
func-names:
- 2
- as-needed
func-style: 2
func-style: 0
linebreak-style: 2
lines-between-class-members: 2
max-len:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ node_modules/
pkg/*
test/.sass-cache/
true-*.gem
.idea
22 changes: 22 additions & 0 deletions lib/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export declare const MODULE_TOKEN = "# Module: ";
export declare const MODULE_NESTING_TOKEN = " :: ";
export declare const SUMMARY_TOKEN = "# SUMMARY ";
export declare const END_SUMMARY_TOKEN = "----------";
export declare const TEST_TOKEN = "Test: ";
export declare const PASS_TOKEN = "\u2714 ";
export declare const FAIL_TOKEN = "\u2716 FAILED: [";
export declare const END_FAIL_TOKEN = "]";
export declare const ASSERT_TOKEN = "ASSERT: ";
export declare const FAILURE_DETAIL_TOKEN = "- ";
export declare const FAILURE_TYPE_START_TOKEN = "[";
export declare const FAILURE_TYPE_END_TOKEN = "]";
export declare const OUTPUT_TOKEN = "Output: ";
export declare const EXPECTED_TOKEN = "Expected: ";
export declare const DETAILS_SEPARATOR_TOKEN = ": ";
export declare const OUTPUT_START_TOKEN = "OUTPUT";
export declare const OUTPUT_END_TOKEN = "END_OUTPUT";
export declare const EXPECTED_START_TOKEN = "EXPECTED";
export declare const EXPECTED_END_TOKEN = "END_EXPECTED";
export declare const CONTAINED_START_TOKEN = "CONTAINED";
export declare const CONTAINED_END_TOKEN = "END_CONTAINED";
export declare const ASSERT_END_TOKEN = "END_ASSERT";
27 changes: 27 additions & 0 deletions lib/constants.js

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

1 change: 1 addition & 0 deletions lib/constants.js.map

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

36 changes: 36 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Options } from 'sass';
import { Node } from 'css';
export interface TrueOptions {
sass?: typeof import('sass');
describe: (description: string, fn: () => void) => void;
it: (description: string, fn: () => void) => void;
contextLines?: number;
}
export interface Assertion {
description: string;
output?: string;
assertionType?: string;
expected?: string;
details?: string;
passed?: boolean;
}
export interface Test {
test: string;
assertions: Assertion[];
}
export interface Module {
module: string;
tests: Test[];
modules?: Module[];
}
export declare type Context = {
modules: Module[];
currentModule?: Module;
currentTest?: Test;
currentAssertion?: Assertion;
currentOutputRules?: Node[];
currentExpectedRules?: Node[];
};
export declare function formatFailureMessage(assertion: Assertion): string;
export declare function runSass(sassOptions: Options, trueOptions: TrueOptions): void;
export declare function parse(rawCss: Readonly<string>, ctxLines?: Readonly<number>): Module[];
Loading