chore: cleanup
This commit is contained in:
parent
2c2c46755e
commit
4b2e4a0da1
|
|
@ -8,21 +8,14 @@ export function transformCssVars(opts: TransformOpts): CodemodPlugin {
|
|||
type: 'codemod',
|
||||
name: 'add prefix to tailwind classes',
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
||||
transform({ scriptASTs, sfcAST, styleASTs, filename, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||
// codemod plugins self-report the number of transforms it made
|
||||
// this is only used to print the stats in CLI output
|
||||
transform({ scriptASTs, sfcAST, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||
let transformCount = 0
|
||||
const { baseColor, config } = opts
|
||||
|
||||
if (config.tailwind?.cssVariables || !baseColor?.inlineColors)
|
||||
return transformCount
|
||||
|
||||
// scriptASTs is an array of Program ASTs
|
||||
// in a js/ts file, this array will only have one item
|
||||
// in a vue file, this array will have one item for each <script> block
|
||||
for (const scriptAST of scriptASTs) {
|
||||
// traverseScriptAST is an alias for the ast-types 'visit' function
|
||||
// see: https://github.com/benjamn/ast-types#ast-traversal
|
||||
traverseScriptAST(scriptAST, {
|
||||
visitLiteral(path) {
|
||||
if (path.parent.value.type !== 'ImportDeclaration' && typeof path.node.value === 'string') {
|
||||
|
|
@ -37,8 +30,6 @@ export function transformCssVars(opts: TransformOpts): CodemodPlugin {
|
|||
}
|
||||
|
||||
if (sfcAST) {
|
||||
// traverseTemplateAST is an alias for the vue-eslint-parser 'AST.traverseNodes' function
|
||||
// see: https://github.com/vuejs/vue-eslint-parser/blob/master/src/ast/traverse.ts#L118
|
||||
traverseTemplateAST(sfcAST, {
|
||||
enterNode(node) {
|
||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
||||
|
|
|
|||
|
|
@ -7,19 +7,11 @@ export function transformImport(opts: TransformOpts): CodemodPlugin {
|
|||
type: 'codemod',
|
||||
name: 'modify import based on user config',
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
||||
transform({ scriptASTs, sfcAST, styleASTs, filename, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||
// codemod plugins self-report the number of transforms it made
|
||||
// this is only used to print the stats in CLI output
|
||||
transform({ scriptASTs, utils: { traverseScriptAST } }) {
|
||||
const transformCount = 0
|
||||
const { config } = opts
|
||||
|
||||
// scriptASTs is an array of Program ASTs
|
||||
// in a js/ts file, this array will only have one item
|
||||
// in a vue file, this array will have one item for each <script> block
|
||||
for (const scriptAST of scriptASTs) {
|
||||
// traverseScriptAST is an alias for the ast-types 'visit' function
|
||||
// see: https://github.com/benjamn/ast-types#ast-traversal
|
||||
traverseScriptAST(scriptAST, {
|
||||
visitImportDeclaration(path) {
|
||||
if (typeof path.node.source.value === 'string') {
|
||||
|
|
|
|||
|
|
@ -8,21 +8,14 @@ export function transformTwPrefix(opts: TransformOpts): CodemodPlugin {
|
|||
type: 'codemod',
|
||||
name: 'add prefix to tailwind classes',
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
||||
transform({ scriptASTs, sfcAST, styleASTs, filename, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||
// codemod plugins self-report the number of transforms it made
|
||||
// this is only used to print the stats in CLI output
|
||||
transform({ scriptASTs, sfcAST, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||
let transformCount = 0
|
||||
const { config } = opts
|
||||
|
||||
if (!config.tailwind?.prefix)
|
||||
return transformCount
|
||||
|
||||
// scriptASTs is an array of Program ASTs
|
||||
// in a js/ts file, this array will only have one item
|
||||
// in a vue file, this array will have one item for each <script> block
|
||||
for (const scriptAST of scriptASTs) {
|
||||
// traverseScriptAST is an alias for the ast-types 'visit' function
|
||||
// see: https://github.com/benjamn/ast-types#ast-traversal
|
||||
traverseScriptAST(scriptAST, {
|
||||
visitLiteral(path) {
|
||||
if (path.parent.value.type !== 'ImportDeclaration' && typeof path.node.value === 'string') {
|
||||
|
|
@ -37,8 +30,6 @@ export function transformTwPrefix(opts: TransformOpts): CodemodPlugin {
|
|||
}
|
||||
|
||||
if (sfcAST) {
|
||||
// traverseTemplateAST is an alias for the vue-eslint-parser 'AST.traverseNodes' function
|
||||
// see: https://github.com/vuejs/vue-eslint-parser/blob/master/src/ast/traverse.ts#L118
|
||||
traverseTemplateAST(sfcAST, {
|
||||
enterNode(node) {
|
||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user