Skip to content

Commit ab23cdb

Browse files
authored
Use gts style (#1663)
1 parent c798fca commit ab23cdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+9153
-8319
lines changed

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./node_modules/gts/"
3+
}

.github/workflows/ci.yml

+11
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ jobs:
3333
- run: npm install
3434
- run: npm test
3535

36+
static_analysis:
37+
name: "Static analysis"
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: actions/setup-node@v2
43+
with: {node-version: "${{ env.NODE_VERSION }}"}
44+
- run: npm install
45+
- run: npm run lint
46+
3647
dart_sass:
3748
name: Dart Sass
3849
runs-on: ubuntu-latest

.prettierrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('gts/.prettierrc.json')
3+
}

.prettierrc.json

-3
This file was deleted.

jest.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
preset: "ts-jest",
3-
testEnvironment: "node",
4-
}
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

lib-js/cli-args.ts

+72-69
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import path from "path"
2-
import yargs from "yargs/yargs"
3-
import { Argv } from "yargs"
4-
import { Compiler, DartCompiler, ExecutableCompiler } from "./compiler"
1+
import path from 'path';
2+
import yargs from 'yargs/yargs';
3+
import {Argv} from 'yargs';
4+
import {Compiler, DartCompiler, ExecutableCompiler} from './compiler';
55

66
export interface CliArgs {
7-
root: string
8-
verbose: boolean
9-
impl: string
10-
compiler: Compiler
11-
interactive: boolean
12-
testDirs: string[]
13-
todoMode?: string
7+
root: string;
8+
verbose: boolean;
9+
impl: string;
10+
compiler: Compiler;
11+
interactive: boolean;
12+
testDirs: string[];
13+
todoMode?: string;
1414
}
1515

1616
const implArgs: Record<string, string[]> = {
17-
"dart-sass": ["--verbose", "--no-unicode", "--no-color"],
18-
libsass: ["--style", "expanded"],
19-
}
17+
'dart-sass': ['--verbose', '--no-unicode', '--no-color'],
18+
libsass: ['--style', 'expanded'],
19+
};
2020

2121
const usageText = `
2222
Usage: ts-node ./sass-spec.ts [options] [spec_directory...]
@@ -26,7 +26,7 @@ that are named input.scss. It will then run a specified binary and check that
2626
the output matches the expected output.
2727
2828
Make sure the command you provide prints to stdout.
29-
`.trim()
29+
`.trim();
3030

3131
/**
3232
* Parse command line args into options used by the sass-spec runner.
@@ -39,93 +39,96 @@ export async function parseArgs(
3939
wrap = (t: Argv<{}>) => t
4040
): Promise<CliArgs> {
4141
const argv = wrap(yargs(cliArgs))
42+
.parserConfiguration({
43+
'parse-numbers': false,
44+
})
4245
.usage(usageText)
4346
.example(
44-
"npm run ./sass-spec.js -- spec/basic",
45-
"Run tests only in the spec/basic folder"
47+
'npm run ./sass-spec.js -- spec/basic',
48+
'Run tests only in the spec/basic folder'
4649
)
47-
.option("verbose", {
48-
alias: "v",
49-
description: "Run verbosely",
50-
type: "boolean",
50+
.option('verbose', {
51+
alias: 'v',
52+
description: 'Run verbosely',
53+
type: 'boolean',
5154
})
52-
.option("dart", {
53-
description: "Run Dart Sass, whose repo should be at the given path",
54-
type: "string",
55+
.option('dart', {
56+
description: 'Run Dart Sass, whose repo should be at the given path',
57+
type: 'string',
5558
})
56-
.option("command", {
57-
alias: "c",
58-
description: "Sets a specific binary to run",
59-
type: "string",
59+
.option('command', {
60+
alias: 'c',
61+
description: 'Sets a specific binary to run',
62+
type: 'string',
6063
})
61-
.conflicts("dart", "command")
62-
.check(({ dart, command }) => {
64+
.conflicts('dart', 'command')
65+
.check(({dart, command}) => {
6366
if (!dart && !command) {
64-
throw new Error("Must specify --dart or --command")
67+
throw new Error('Must specify --dart or --command');
6568
} else {
66-
return true
69+
return true;
6770
}
6871
})
69-
.option("cmd-args", {
70-
description: "Pass args to command or Dart Sass",
71-
type: "string",
72+
.option('cmd-args', {
73+
description: 'Pass args to command or Dart Sass',
74+
type: 'string',
7275
})
73-
.option("impl", {
74-
description: "Sets the name of the implementation being tested.",
75-
type: "string",
76+
.option('impl', {
77+
description: 'Sets the name of the implementation being tested.',
78+
type: 'string',
7679
})
77-
.options("run-todo", {
78-
description: "Run any tests marked as todo",
79-
type: "boolean",
80+
.options('run-todo', {
81+
description: 'Run any tests marked as todo',
82+
type: 'boolean',
8083
})
81-
.options("probe-todo", {
82-
description: "Run and report tests marked as todo that unexpectedly pass",
83-
type: "boolean",
84+
.options('probe-todo', {
85+
description: 'Run and report tests marked as todo that unexpectedly pass',
86+
type: 'boolean',
8487
})
85-
.conflicts("run-todo", "probe-todo")
86-
.option("root-path", {
88+
.conflicts('run-todo', 'probe-todo')
89+
.option('root-path', {
8790
description:
88-
"The root path to start searching for tests and test configuration, and the path to pass into --load-path",
89-
type: "string",
90-
default: "spec",
91+
'The root path to start searching for tests and test configuration, and the path to pass into --load-path',
92+
type: 'string',
93+
default: 'spec',
9194
})
92-
.options("interactive", {
95+
.options('interactive', {
9396
description:
94-
"When a test fails, enter into a dialog for how to handle it",
95-
type: "boolean",
97+
'When a test fails, enter into a dialog for how to handle it',
98+
type: 'boolean',
9699
default: false,
97-
}).argv
100+
}).argv;
98101

99-
const root = path.resolve(process.cwd(), argv["root-path"])
102+
const root = path.resolve(process.cwd(), argv['root-path']);
100103

101104
const args: Partial<CliArgs> = {
102105
root,
103106
verbose: argv.verbose,
104107
interactive: argv.interactive,
105-
testDirs: argv._,
106-
todoMode: argv["run-todo"]
107-
? "run"
108-
: argv["probe-todo"]
109-
? "probe"
108+
testDirs: argv._ as string[],
109+
todoMode: argv['run-todo']
110+
? 'run'
111+
: argv['probe-todo']
112+
? 'probe'
110113
: undefined,
111-
}
112-
args.impl = argv.dart ? "dart-sass" : argv.impl!
113-
let cmdArgs = implArgs[args.impl] ?? []
114-
cmdArgs.push(`--load-path=${root}`)
115-
if (argv["cmd-args"]) {
116-
cmdArgs = cmdArgs.concat(argv["cmd-args"].split(" "))
114+
};
115+
args.impl = argv.dart ? 'dart-sass' : argv.impl!;
116+
let cmdArgs = implArgs[args.impl] ?? [];
117+
cmdArgs.push(`--load-path=${root}`);
118+
if (argv['cmd-args']) {
119+
cmdArgs = cmdArgs.concat(argv['cmd-args'].split(' '));
117120
}
118121

119122
if (argv.command) {
120123
args.compiler = new ExecutableCompiler(
121124
path.resolve(process.cwd(), argv.command),
122125
cmdArgs
123-
)
126+
);
124127
}
125128
if (argv.dart) {
126-
const repoPath = path.resolve(process.cwd(), argv.dart)
127-
args.compiler = await DartCompiler.fromRepo(repoPath, cmdArgs)
129+
const repoPath = path.resolve(process.cwd(), argv.dart);
130+
args.compiler = await DartCompiler.fromRepo(repoPath, cmdArgs);
128131
}
129132

130-
return args as CliArgs
133+
return args as CliArgs;
131134
}

0 commit comments

Comments
 (0)