Skip to content

Commit be518b8

Browse files
authored
Updating deprecations.js file to be more straightforward (#1581)
* Updating deprecations.js file to be more straightforward * Create poor-coins-fix.md * Remove tests * Adding more info about the deprecation to the doc * Title section * Moving data to deprecations.json * Moving data to deprecations.json * Lint only scss files
1 parent c3b4a0c commit be518b8

File tree

9 files changed

+570
-922
lines changed

9 files changed

+570
-922
lines changed

.changeset/poor-coins-fix.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/css": minor
3+
---
4+
5+
Updating deprecations.js file to be more straightforward

__tests__/css.test.js

-58
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {
22
getCurrentVersion,
3-
getDeprecatedSelectors,
4-
getDeprecatedVariables,
53
getPackageStats,
64
getSelectorDiff,
75
getVariableDiff
@@ -10,17 +8,6 @@ import semver from 'semver'
108

119
let selectorsDiff, variablesDiff, version
1210

13-
// Because of a change in analyzer this was incorrectly in the list
14-
const variableAllowList = ['$marketing-all-spacers']
15-
const selectorAllowList = [
16-
'.Truncate .Truncate-text',
17-
'.Truncate .Truncate-text+.Truncate-text',
18-
'.Truncate .Truncate-text.Truncate-text--expandable:active',
19-
'.Truncate .Truncate-text.Truncate-text--expandable:focus',
20-
'.Truncate .Truncate-text.Truncate-text--expandable:hover',
21-
'.Truncate .Truncate-text.Truncate-text--primary'
22-
]
23-
2411
beforeAll(async () => {
2512
selectorsDiff = getSelectorDiff()
2613
variablesDiff = getVariableDiff()
@@ -33,48 +20,3 @@ describe('css', () => {
3320
expect(supportStats.size).toEqual(0)
3421
})
3522
})
36-
37-
describe('deprecations', () => {
38-
it('A selector was marked as deprecated but not removed from the codebase', () => {
39-
const removed = selectorsDiff['removed']
40-
const deprecations = getDeprecatedSelectors(version.raw)
41-
if (deprecations.length) {
42-
// Selectors were marked to be deprecated in this version,
43-
// but were not removed from the codebase. Please remove these selectors.
44-
expect(deprecations.sort()).toEqual(removed.sort()) // eslint-disable-line jest/no-conditional-expect
45-
}
46-
})
47-
48-
it('A selector was removed from the codebase but not added to upcoming major release deprecations file.', () => {
49-
const removedSelectors = selectorsDiff['removed'].filter(v => !selectorAllowList.includes(v))
50-
51-
if (version.minor !== 0 && version.patch !== 0) {
52-
const nextMajor = semver.inc(version.raw, 'major')
53-
const deprecations = getDeprecatedSelectors(nextMajor)
54-
// Some classes were removed from the codebase, but not found
55-
// in the next upcoming major release deprecation.js
56-
expect(deprecations.sort()).toEqual(expect.arrayContaining(removedSelectors.sort())) // eslint-disable-line jest/no-conditional-expect
57-
}
58-
})
59-
60-
it('A variable was marked as deprecated but not removed from the codebase', () => {
61-
const removed = variablesDiff.removed
62-
const deprecations = getDeprecatedVariables(version.raw)
63-
if (deprecations.length) {
64-
// Variables were marked to be deprecated in this version,
65-
// but were not removed from the codebase. Please remove these variables.
66-
expect(deprecations.sort()).toEqual(removed.sort()) // eslint-disable-line jest/no-conditional-expect
67-
}
68-
})
69-
70-
it('A variable was removed from the codebase and added to upcoming major release deprecations file.', () => {
71-
const removed = variablesDiff.removed.filter(v => !variableAllowList.includes(v))
72-
if (version.minor !== 0 && version.patch !== 0) {
73-
const nextMajor = semver.inc(version.raw, 'major')
74-
const deprecations = getDeprecatedVariables(nextMajor)
75-
// Some variables were removed from the codebase, but not found
76-
// in the next upcoming major release deprecation.json
77-
expect(deprecations).toEqual(expect.arrayContaining(removed)) // eslint-disable-line jest/no-conditional-expect
78-
}
79-
})
80-
})

__tests__/utils/css.js

-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ export function getCurrentVersion() {
3333
return semver.parse(pkg.version)
3434
}
3535

36-
export function getDeprecatedSelectors(version) {
37-
if (getCurrentVersion().raw === version) return []
38-
let deprecations = JSON.parse(fs.readFileSync(join(currentPath, './dist/deprecations.json')))
39-
deprecations = deprecations.versions[version] || []
40-
return deprecations.reduce((list, deprecation) => list.concat(deprecation.selectors), []).filter(v => v)
41-
}
42-
43-
export function getDeprecatedVariables(version) {
44-
if (getCurrentVersion().raw === version) return []
45-
let deprecations = JSON.parse(fs.readFileSync(join(currentPath, './dist/deprecations.json')))
46-
deprecations = deprecations.versions[version] || []
47-
return deprecations.reduce((list, deprecation) => list.concat(deprecation.variables), []).filter(v => v)
48-
}
49-
5036
export function getPackageStats(packageName) {
5137
const stats = JSON.parse(fs.readFileSync(join(currentPath, './dist', `./stats/${packageName}.json`)))
5238
return stats

0 commit comments

Comments
 (0)