@instructure/ui-codemods 8.14.1-snapshot.7 → 8.14.1-snapshot.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,100 +0,0 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- const getClassDeclarations = require('../utils/getClassDeclarations')
26
- const findDeprecatedProp = require('../utils/findDeprecatedProp')
27
-
28
- /**
29
- * Find and replace variable declarations
30
- *
31
- * Example:
32
- * const [name] = this.props[name]
33
- * const { [name] } = this.props
34
- */
35
- module.exports = function replaceVariableDeclarations(j, root, config) {
36
- let hasModifications = false
37
-
38
- getClassDeclarations(j, root, config).forEach((path) => {
39
- const name = path.value.id.name
40
-
41
- j(path)
42
- .find(j.VariableDeclarator)
43
- .forEach((v) => {
44
- // const [name] = this.props[name]
45
- if (v.value.id.name) {
46
- const prop = v.value.id.name
47
- const match = findDeprecatedProp(config, name, prop)
48
-
49
- if (match) {
50
- // Find the init object (should be `this.props` or `props`)
51
- if (
52
- v.value.init.object.name === 'props' ||
53
- v.value.init.object.property.name === 'props'
54
- ) {
55
- // Find the actual identifier
56
- j(v)
57
- .find(j.Identifier)
58
- .forEach((i) => {
59
- if (i.value.name === prop) {
60
- hasModifications = true
61
- j(i).replaceWith(j.identifier(match.new))
62
- }
63
- })
64
- }
65
- }
66
- }
67
-
68
- // const { [name] } = this.props[name]
69
- if (v.value.id.properties) {
70
- // Find destructured properties
71
- j(v.value.id)
72
- .find(j.Property)
73
- .forEach((p) => {
74
- const prop = p.value.value.name
75
- const match = findDeprecatedProp(config, name, prop)
76
-
77
- if (match) {
78
- // Find the init object (should be `this.props` or `props`)
79
- if (
80
- v.value.init.name === 'props' ||
81
- v.value.init.property.name === 'props'
82
- ) {
83
- // Find the actual identifier
84
- j(p)
85
- .find(j.Identifier)
86
- .forEach((i) => {
87
- if (i.value.name === prop) {
88
- hasModifications = true
89
- j(i).replaceWith(j.identifier(match.new))
90
- }
91
- })
92
- }
93
- }
94
- })
95
- }
96
- })
97
- })
98
-
99
- return hasModifications
100
- }
@@ -1,37 +0,0 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- /**
26
- * Get all class declarations that match a component which has deprecated properties
27
- *
28
- * @param {object} j jscodeshift API
29
- * @param {object} root AST root node
30
- * @param {object} config Deprecated property configuration
31
- * @return {array} Filtered collection of component class declarations
32
- */
33
- module.exports = function getClassDeclarations(j, root, config) {
34
- return root
35
- .find(j.ClassDeclaration)
36
- .filter((path) => typeof config[path.value.id.name] !== 'undefined')
37
- }