chore: cleanup
This commit is contained in:
parent
2c2c46755e
commit
4b2e4a0da1
|
|
@ -8,21 +8,14 @@ export function transformCssVars(opts: TransformOpts): CodemodPlugin {
|
||||||
type: 'codemod',
|
type: 'codemod',
|
||||||
name: 'add prefix to tailwind classes',
|
name: 'add prefix to tailwind classes',
|
||||||
|
|
||||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
transform({ scriptASTs, sfcAST, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||||
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
|
|
||||||
let transformCount = 0
|
let transformCount = 0
|
||||||
const { baseColor, config } = opts
|
const { baseColor, config } = opts
|
||||||
|
|
||||||
if (config.tailwind?.cssVariables || !baseColor?.inlineColors)
|
if (config.tailwind?.cssVariables || !baseColor?.inlineColors)
|
||||||
return transformCount
|
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) {
|
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, {
|
traverseScriptAST(scriptAST, {
|
||||||
visitLiteral(path) {
|
visitLiteral(path) {
|
||||||
if (path.parent.value.type !== 'ImportDeclaration' && typeof path.node.value === 'string') {
|
if (path.parent.value.type !== 'ImportDeclaration' && typeof path.node.value === 'string') {
|
||||||
|
|
@ -37,8 +30,6 @@ export function transformCssVars(opts: TransformOpts): CodemodPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sfcAST) {
|
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, {
|
traverseTemplateAST(sfcAST, {
|
||||||
enterNode(node) {
|
enterNode(node) {
|
||||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
if (node.type === 'Literal' && typeof node.value === 'string') {
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,11 @@ export function transformImport(opts: TransformOpts): CodemodPlugin {
|
||||||
type: 'codemod',
|
type: 'codemod',
|
||||||
name: 'modify import based on user config',
|
name: 'modify import based on user config',
|
||||||
|
|
||||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
transform({ scriptASTs, utils: { traverseScriptAST } }) {
|
||||||
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
|
|
||||||
const transformCount = 0
|
const transformCount = 0
|
||||||
const { config } = opts
|
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) {
|
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, {
|
traverseScriptAST(scriptAST, {
|
||||||
visitImportDeclaration(path) {
|
visitImportDeclaration(path) {
|
||||||
if (typeof path.node.source.value === 'string') {
|
if (typeof path.node.source.value === 'string') {
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,14 @@ export function transformTwPrefix(opts: TransformOpts): CodemodPlugin {
|
||||||
type: 'codemod',
|
type: 'codemod',
|
||||||
name: 'add prefix to tailwind classes',
|
name: 'add prefix to tailwind classes',
|
||||||
|
|
||||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
transform({ scriptASTs, sfcAST, utils: { traverseScriptAST, traverseTemplateAST } }) {
|
||||||
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
|
|
||||||
let transformCount = 0
|
let transformCount = 0
|
||||||
const { config } = opts
|
const { config } = opts
|
||||||
|
|
||||||
if (!config.tailwind?.prefix)
|
if (!config.tailwind?.prefix)
|
||||||
return transformCount
|
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) {
|
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, {
|
traverseScriptAST(scriptAST, {
|
||||||
visitLiteral(path) {
|
visitLiteral(path) {
|
||||||
if (path.parent.value.type !== 'ImportDeclaration' && typeof path.node.value === 'string') {
|
if (path.parent.value.type !== 'ImportDeclaration' && typeof path.node.value === 'string') {
|
||||||
|
|
@ -37,8 +30,6 @@ export function transformTwPrefix(opts: TransformOpts): CodemodPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sfcAST) {
|
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, {
|
traverseTemplateAST(sfcAST, {
|
||||||
enterNode(node) {
|
enterNode(node) {
|
||||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
if (node.type === 'Literal' && typeof node.value === 'string') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user