• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

streetsidesoftware / cspell / 16081362062

04 Jul 2025 09:50PM UTC coverage: 92.393% (-0.006%) from 92.399%
16081362062

push

github

web-flow
fix: Add toml config reader/writer (#7565)

13086 of 15456 branches covered (84.67%)

23 of 26 new or added lines in 3 files covered. (88.46%)

16020 of 17339 relevant lines covered (92.39%)

29788.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/packages/cspell-config-lib/src/CSpellConfigFile/CSpellConfigFileToml.ts
1
import type { CSpellSettings } from '@cspell/cspell-types';
2
import { parse, stringify } from 'smol-toml';
3

4
import { ImplCSpellConfigFile } from '../CSpellConfigFile.js';
5
import type { TextFile } from '../TextFile.js';
6
import { ParseError } from './Errors.js';
7

8
export class CSpellConfigFileToml extends ImplCSpellConfigFile {
9
    constructor(
10
        readonly url: URL,
11✔
11
        settings: CSpellSettings,
12
    ) {
13
        super(url, settings);
11✔
14
    }
15

16
    serialize() {
17
        return stringify(this.settings) + '\n';
9✔
18
    }
19

20
    removeAllComments(): this {
NEW
21
        return this;
×
22
    }
23

24
    setSchema(schema: string): this {
25
        this.settings.$schema = schema;
1✔
26
        return this;
1✔
27
    }
28

29
    setComment(_field: keyof CSpellSettings, _comment: string, _inline?: boolean): this {
30
        return this;
2✔
31
    }
32

33
    public static parse(file: TextFile): CSpellConfigFileToml {
34
        try {
12✔
35
            const cspell: CSpellSettings | unknown = parse(file.content);
12✔
36
            if (!isCSpellSettings(cspell)) {
10!
NEW
37
                throw new ParseError(file.url);
×
38
            }
39

40
            const cfg = new CSpellConfigFileToml(file.url, cspell);
10✔
41
            return cfg;
10✔
42
        } catch (cause) {
43
            if (cause instanceof ParseError) {
2!
NEW
44
                throw cause;
×
45
            }
46
            throw new ParseError(file.url, undefined, { cause });
2✔
47
        }
48
    }
49
}
50

51
export function parseCSpellConfigFileToml(file: TextFile): CSpellConfigFileToml {
52
    return CSpellConfigFileToml.parse(file);
8✔
53
}
54

55
function isCSpellSettings(cfg: unknown): cfg is CSpellSettings {
56
    return !(!cfg || typeof cfg !== 'object' || Array.isArray(cfg));
10✔
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc