-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support ESM configuration (#4995)
Co-authored-by: street-side-software-automation[bot] <74785433+street-side-software-automation[bot]@users.noreply.github.com>
- Loading branch information
1 parent
947fad2
commit 680eb86
Showing
69 changed files
with
1,726 additions
and
923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/cspell-config-lib/src/CSpellConfigFile/CSpellConfigFileInMemory.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { CSpellSettings } from '@cspell/cspell-types'; | ||
import { describe, expect, test } from 'vitest'; | ||
|
||
import { CSpellConfigFileInMemory } from './CSpellConfigFileInMemory.js'; | ||
|
||
describe('CSpellConfigFileInMemory', () => { | ||
const url = new URL('https://example.com/config'); | ||
const settings: CSpellSettings = {}; | ||
|
||
test('should create an instance of CSpellConfigFileInMemory', () => { | ||
const configFile = new CSpellConfigFileInMemory(url, settings); | ||
expect(configFile).toBeInstanceOf(CSpellConfigFileInMemory); | ||
}); | ||
|
||
test('should have the correct URL', () => { | ||
const configFile = new CSpellConfigFileInMemory(url, settings); | ||
expect(configFile.url).toEqual(url); | ||
}); | ||
|
||
test('should have the correct settings', () => { | ||
const configFile = new CSpellConfigFileInMemory(url, settings); | ||
expect(configFile.settings).toEqual(settings); | ||
}); | ||
|
||
test('should be readonly', () => { | ||
const configFile = new CSpellConfigFileInMemory(url, settings); | ||
expect(configFile.readonly).toBe(true); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
packages/cspell-config-lib/src/CSpellConfigFile/CSpellConfigFileInMemory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { CSpellSettings } from '@cspell/cspell-types'; | ||
|
||
import { ImplCSpellConfigFile } from '../CSpellConfigFile.js'; | ||
|
||
export class CSpellConfigFileInMemory extends ImplCSpellConfigFile { | ||
constructor( | ||
/** A url representing where it might exist, used to resolve imports. */ | ||
readonly url: URL, | ||
readonly settings: CSpellSettings, | ||
) { | ||
super(url, settings); | ||
} | ||
|
||
get readonly(): boolean { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
/** @type { import("@cspell/cspell-types").CSpellUserSettings } */ | ||
const cspell = { | ||
description: 'cspell.config.cjs file in samples/esm-config', | ||
languageSettings: [ | ||
{ | ||
languageId: 'cpp', | ||
allowCompoundWords: false, | ||
patterns: [ | ||
{ | ||
name: 'pound-includes', | ||
pattern: /^\s*#include.*/g, | ||
}, | ||
], | ||
ignoreRegExpList: ['pound-includes'], | ||
}, | ||
], | ||
dictionaryDefinitions: [ | ||
{ | ||
name: 'custom-words', | ||
path: './custom-words.txt', | ||
}, | ||
], | ||
dictionaries: ['custom-words'], | ||
}; | ||
|
||
module.exports = cspell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** @type { import("@cspell/cspell-types").CSpellUserSettings } */ | ||
|
||
const cspell = { | ||
description: 'cspell.config.js file in samples/esm-config', | ||
languageSettings: [ | ||
{ | ||
languageId: 'cpp', | ||
allowCompoundWords: false, | ||
patterns: [ | ||
{ | ||
name: 'pound-includes', | ||
pattern: /^\s*#include.*/g, | ||
}, | ||
], | ||
ignoreRegExpList: ['pound-includes'], | ||
}, | ||
], | ||
dictionaryDefinitions: [ | ||
{ | ||
name: 'custom-words', | ||
path: './custom-words.txt', | ||
}, | ||
], | ||
dictionaries: ['custom-words'], | ||
}; | ||
|
||
export default cspell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** @type { import("@cspell/cspell-types").CSpellUserSettings } */ | ||
|
||
const cspell = { | ||
description: 'cspell.config.mjs file in samples/esm-config', | ||
languageSettings: [ | ||
{ | ||
languageId: 'cpp', | ||
allowCompoundWords: false, | ||
patterns: [ | ||
{ | ||
name: 'pound-includes', | ||
pattern: /^\s*#include.*/g, | ||
}, | ||
], | ||
ignoreRegExpList: ['pound-includes'], | ||
}, | ||
], | ||
dictionaryDefinitions: [ | ||
{ | ||
name: 'custom-words', | ||
path: './custom-words.txt', | ||
}, | ||
], | ||
dictionaries: ['custom-words'], | ||
}; | ||
|
||
export default cspell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
here | ||
are | ||
some | ||
words |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Here are some words. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Sample README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "package-test", | ||
"cspell": { | ||
"words": [ | ||
"package" | ||
] | ||
} | ||
} |
Oops, something went wrong.