Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit e4b305a

Browse files
committed
fix: use walk from svete/compier to estree-walker
micantoine#100
1 parent 56e5be7 commit e4b305a

File tree

8 files changed

+13
-12
lines changed

8 files changed

+13
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"dependencies": {
5858
"acorn": "^8.5.0",
5959
"big.js": "^6.1.1",
60+
"estree-walker": "^3.0.0",
6061
"magic-string": "^0.25.7"
6162
},
6263
"devDependencies": {
@@ -68,7 +69,6 @@
6869
"eslint-config-airbnb-base": "^14.2.0",
6970
"eslint-config-prettier": "^6.15.0",
7071
"eslint-plugin-import": "^2.22.1",
71-
"estree-walker": "^3.0.0",
7272
"husky": "^4.3.0",
7373
"jest": "^26.0.1",
7474
"lint-staged": "^10.5.1",

src/parsers/importDeclaration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
import path from 'path';
33
import fs, { constants } from 'fs';
44
import MagicString from 'magic-string';
5-
import { parse, walk } from 'svelte/compiler';
5+
import { parse } from 'svelte/compiler';
6+
import { walk } from 'estree-walker';
67
import type { TemplateNode } from 'svelte/types/compiler/interfaces.d';
78
import type Processor from '../processors/processor';
89

910
/**
1011
* Parse CssModules Imports
1112
*/
1213
export default (processor: Processor): void => {
13-
const ast = (processor.ast as unknown) as TemplateNode;
14+
const ast = processor.ast as unknown as TemplateNode;
1415
const backup = {
1516
ast: processor.ast,
1617
magicContent: processor.magicContent,

src/parsers/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { walk } from 'svelte/compiler';
1+
import { walk } from 'estree-walker';
22
import type { Attribute, TemplateNode } from 'svelte/types/compiler/interfaces.d';
33
import type Processor from '../processors/processor';
44

src/processors/mixed.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { walk } from 'svelte/compiler';
1+
import { walk } from 'estree-walker';
22
import type { Ast, TemplateNode } from 'svelte/types/compiler/interfaces.d';
33
import type { PluginOptions } from '../types';
44
import Processor from './processor';
@@ -31,7 +31,7 @@ const updateSelectorBoundaries = (
3131
* @param processor The CSS Module Processor
3232
*/
3333
const parser = (processor: Processor): void => {
34-
const ast = (processor.ast as unknown) as TemplateNode;
34+
const ast = processor.ast as unknown as TemplateNode;
3535
walk(ast, {
3636
enter(baseNode) {
3737
const node = baseNode as TemplateNode;

src/processors/native.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { walk } from 'svelte/compiler';
1+
import { walk } from 'estree-walker';
22
import type { Ast, TemplateNode } from 'svelte/types/compiler/interfaces.d';
33
import type { PluginOptions } from '../types';
44
import Processor from './processor';
@@ -32,7 +32,7 @@ const updateSelectorBoundaries = (
3232
* @param processor The CSS Module Processor
3333
*/
3434
const parser = (processor: Processor): void => {
35-
const ast = (processor.ast as unknown) as TemplateNode;
35+
const ast = processor.ast as unknown as TemplateNode;
3636
let selectorBoundaries: Boundaries[] = [];
3737

3838
walk(ast, {

src/processors/scoped.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { walk } from 'svelte/compiler';
1+
import { walk } from 'estree-walker';
22
import type { Ast, TemplateNode } from 'svelte/types/compiler/interfaces.d';
33
import type { PluginOptions } from '../types';
44
import Processor from './processor';
@@ -8,7 +8,7 @@ import Processor from './processor';
88
* @param processor The CSS Module Processor
99
*/
1010
const parser = (processor: Processor): void => {
11-
const ast = (processor.ast as unknown) as TemplateNode;
11+
const ast = processor.ast as unknown as TemplateNode;
1212
walk(ast, {
1313
enter(baseNode) {
1414
const node = baseNode as TemplateNode;

tasks/parser.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { readdir, lstat, readFile, existsSync, writeFile } from 'fs';
33
import { resolve, dirname } from 'path';
44
import { Parser } from 'acorn';
5-
import { walk } from 'svelte/compiler';
5+
import { walk } from 'estree-walker';
66
import MagicString from 'magic-string';
77

88
const parseDir = (dir) => {

test/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const svelte = require('svelte/compiler');
1+
const svelte = require('estree-walker');
22
const cssModules = require('../');
33

44
module.exports = async ({ source }, options) => {

0 commit comments

Comments
 (0)