Skip to content

Commit 7c23798

Browse files
authored
BREAKING: graduate useUnstableLocations to useLocations (#437)
1 parent ad8198a commit 7c23798

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

src/atrules/atrules.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ AtRules('finds @font-face', () => {
297297
}
298298
}`
299299
const actual = analyze(fixture, {
300-
useUnstableLocations: true
301-
}).atrules.fontface.__unstable__uniqueWithLocations
300+
useLocations: true
301+
}).atrules.fontface.uniqueWithLocations
302302
const expected = {
303303
5: [{
304304
line: 2,

src/collection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export class Collection {
6161
* uniquenessRatio: number;
6262
* unique: Record<string, number>;
6363
* } & ({
64-
* __unstable__uniqueWithLocations: Record<string, CssLocation[]>
64+
* uniqueWithLocations: Record<string, CssLocation[]>
6565
* } | {
66-
* __unstable__uniqueWithLocations?: undefined
66+
* uniqueWithLocations?: undefined
6767
* })}
6868
*/
6969
c() {
@@ -103,7 +103,7 @@ export class Collection {
103103
}
104104

105105
if (useLocations) {
106-
data.__unstable__uniqueWithLocations = Object.fromEntries(uniqueWithLocations)
106+
data.uniqueWithLocations = Object.fromEntries(uniqueWithLocations)
107107
}
108108

109109
return data

src/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ function ratio(part, total) {
5252
}
5353

5454
let defaults = {
55-
useUnstableLocations: false
55+
useLocations: false
5656
}
5757

5858
/**
5959
* @typedef Options
60-
* @property {boolean} useUnstableLocations **WARNING: EXPERIMENTAL!** Use Locations (`{ 'item': [{ line, column, offset, length }] }`) instead of a regular count per occurrence (`{ 'item': 3 }`)
60+
* @property {boolean} useLocations Use Locations (`{ 'item': [{ line, column, offset, length }] }`) instead of a regular count per occurrence (`{ 'item': 3 }`)
6161
*/
6262

6363
/**
@@ -67,7 +67,7 @@ let defaults = {
6767
*/
6868
export function analyze(css, options = {}) {
6969
let settings = Object.assign({}, defaults, options)
70-
let useLocations = settings.useUnstableLocations === true
70+
let useLocations = settings.useLocations === true
7171
let start = Date.now()
7272

7373
/**
@@ -91,7 +91,7 @@ export function analyze(css, options = {}) {
9191
let embedSize = 0
9292
let embedTypes = {
9393
total: 0,
94-
/** @type {Map<string, { size: number, count: number } & ({ __unstable__uniqueWithLocations?: undefined } | ({ __unstable__uniqueWithLocations: { offset: number, line: number, column: number, length: number }[] })) }>} */
94+
/** @type {Map<string, { size: number, count: number } & ({ uniqueWithLocations?: undefined } | ({ uniqueWithLocations: { offset: number, line: number, column: number, length: number }[] })) }>} */
9595
unique: new Map()
9696
}
9797

@@ -415,15 +415,15 @@ export function analyze(css, options = {}) {
415415
item.size += size
416416
embedTypes.unique.set(type, item)
417417
if (useLocations) {
418-
item.__unstable__uniqueWithLocations.push(loc)
418+
item.uniqueWithLocations.push(loc)
419419
}
420420
} else {
421421
let item = {
422422
count: 1,
423423
size
424424
}
425425
if (useLocations) {
426-
item.__unstable__uniqueWithLocations = [loc]
426+
item.uniqueWithLocations = [loc]
427427
}
428428
embedTypes.unique.set(type, item)
429429
}
@@ -694,7 +694,7 @@ export function analyze(css, options = {}) {
694694
})
695695

696696
let embeddedContent = embeds.c()
697-
delete embeddedContent.__unstable__uniqueWithLocations
697+
delete embeddedContent.uniqueWithLocations
698698

699699
let totalUniqueDeclarations = uniqueDeclarations.size
700700

@@ -742,7 +742,7 @@ export function analyze(css, options = {}) {
742742
unique: fontfaces,
743743
uniquenessRatio: fontFacesCount === 0 ? 0 : 1,
744744
}, useLocations ? {
745-
__unstable__uniqueWithLocations: fontfaces_with_loc.c().__unstable__uniqueWithLocations,
745+
uniqueWithLocations: fontfaces_with_loc.c().uniqueWithLocations,
746746
} : {}),
747747
import: imports.c(),
748748
media: assign(

src/selectors/pseudos.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ test('logs the whole parent selector when using locations', () => {
3333
let actual = analyze(`
3434
a:hover,
3535
a:lang(en) {}`,
36-
{ useUnstableLocations: true }
37-
).selectors.pseudoClasses.__unstable__uniqueWithLocations
36+
{ useLocations: true }
37+
).selectors.pseudoClasses.uniqueWithLocations
3838
let expected = {
3939
'hover': [
4040
{

src/selectors/selectors.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ Selectors('tracks combinator locations', () => {
424424
a[attr] b {}
425425
`
426426
let result = analyze(css, {
427-
useUnstableLocations: true
427+
useLocations: true
428428
})
429429
let actual = result.selectors.combinators
430430

431-
assert.equal(actual.__unstable__uniqueWithLocations, {
431+
assert.equal(actual.uniqueWithLocations, {
432432
' ': [
433433
{
434434
line: 2,
@@ -465,7 +465,7 @@ Selectors('tracks combinator locations', () => {
465465
]
466466
})
467467

468-
let as_strings = actual.__unstable__uniqueWithLocations[' ']
468+
let as_strings = actual.uniqueWithLocations[' ']
469469
.map(loc => css.substring(loc.offset, loc.offset + loc.length))
470470
assert.equal(as_strings, [
471471
' ',
@@ -491,7 +491,7 @@ Selectors('Can keep track of selector locations if we ask it to do so', () => {
491491
}
492492
}
493493
`
494-
let actual = analyze(fixture, { useUnstableLocations: true }).selectors.complexity.__unstable__uniqueWithLocations
494+
let actual = analyze(fixture, { useLocations: true }).selectors.complexity.uniqueWithLocations
495495
let expected = {
496496
'1': [
497497
{

src/stylesheet/stylesheet.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Stylesheet('measures base64 contents - with locations', () => {
178178
}
179179
`
180180

181-
const actual = analyze(fixture, { useUnstableLocations: true }).stylesheet.embeddedContent
181+
const actual = analyze(fixture, { useLocations: true }).stylesheet.embeddedContent
182182
const expected = {
183183
total: 5,
184184
totalUnique: 5,
@@ -202,7 +202,7 @@ Stylesheet('measures base64 contents - with locations', () => {
202202
'image/gif': {
203203
count: 1,
204204
size: 310,
205-
__unstable__uniqueWithLocations: [
205+
uniqueWithLocations: [
206206
{
207207
line: 5,
208208
column: 9,
@@ -214,7 +214,7 @@ Stylesheet('measures base64 contents - with locations', () => {
214214
'image/svg+xml': {
215215
count: 4,
216216
size: 2027,
217-
__unstable__uniqueWithLocations: [
217+
uniqueWithLocations: [
218218
{
219219
line: 13,
220220
column: 19,

src/values/colors.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,9 @@ Colors('Lists locations when unstable flag is set', () => {
10631063
background-color: red;
10641064
}
10651065
`
1066-
let actual = analyze(css, { useUnstableLocations: true })
1066+
let actual = analyze(css, { useLocations: true })
10671067

1068-
assert.equal(actual.values.colors.__unstable__uniqueWithLocations, {
1068+
assert.equal(actual.values.colors.uniqueWithLocations, {
10691069
'red': [
10701070
{
10711071
line: 3,

0 commit comments

Comments
 (0)