Skip to content

Commit 7bae80a

Browse files
committed
update parser and some fixes
1 parent d3fd17c commit 7bae80a

File tree

9 files changed

+131
-135
lines changed

9 files changed

+131
-135
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Example **eslint.config.js**:
183183
import eslintPluginSvelte from 'eslint-plugin-svelte';
184184
import svelteConfig from './svelte.config.js';
185185
export default [
186-
...eslintPluginSvelte.configs['flat/recommended'],
186+
...eslintPluginSvelte.configs.recommended,
187187
{
188188
files: [
189189
'**/*.svelte',

docs/user-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Example **eslint.config.js**:
133133
import eslintPluginSvelte from 'eslint-plugin-svelte';
134134
import svelteConfig from './svelte.config.js';
135135
export default [
136-
...eslintPluginSvelte.configs['flat/recommended'],
136+
...eslintPluginSvelte.configs.recommended,
137137
{
138138
files: [
139139
'**/*.svelte',

packages/eslint-plugin-svelte/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"postcss-safe-parser": "^6.0.0",
6767
"postcss-selector-parser": "^7.0.0",
6868
"semver": "^7.6.3",
69-
"svelte-eslint-parser": "^1.0.0-next.1"
69+
"svelte-eslint-parser": "^1.0.0-next.3"
7070
},
7171
"devDependencies": {
7272
"@babel/core": "^7.26.0",
+4-42
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,6 @@
1-
import './rule-types.js';
2-
import type { RuleModule } from './types.js';
3-
import { rules as ruleList } from './utils/rules.js';
4-
import base, { setPluginObject } from './configs/flat/base.js';
5-
import recommended from './configs/flat/recommended.js';
6-
import prettier from './configs/flat/prettier.js';
7-
import all from './configs/flat/all.js';
8-
import * as processor from './processor/index.js';
9-
import * as meta from './meta.js';
1+
import * as plugin from './main.js';
2+
import { setPluginObject } from './configs/flat/base.js';
3+
setPluginObject(plugin);
104

11-
export const configs = {
12-
base,
13-
recommended,
14-
prettier,
15-
all,
16-
// For backward compatibility
17-
'flat/base': base,
18-
'flat/recommended': recommended,
19-
'flat/prettier': prettier,
20-
'flat/all': all
21-
};
22-
23-
export const rules = ruleList.reduce(
24-
(obj, r) => {
25-
obj[r.meta.docs.ruleName] = r;
26-
return obj;
27-
},
28-
{} as { [key: string]: RuleModule }
29-
);
30-
31-
export { meta };
32-
export const processors = {
33-
'.svelte': processor,
34-
svelte: processor
35-
};
36-
37-
const plugin = {
38-
rules,
39-
configs,
40-
meta,
41-
processors
42-
};
43-
setPluginObject(plugin as never);
5+
export * from './main.js';
446
export default plugin;
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import './rule-types.js';
2+
import type { RuleModule } from './types.js';
3+
import { rules as ruleList } from './utils/rules.js';
4+
import base from './configs/flat/base.js';
5+
import recommended from './configs/flat/recommended.js';
6+
import prettier from './configs/flat/prettier.js';
7+
import all from './configs/flat/all.js';
8+
import * as processor from './processor/index.js';
9+
import * as metaModule from './meta.js';
10+
import type { Rule } from 'eslint';
11+
12+
export const configs = {
13+
base,
14+
recommended,
15+
prettier,
16+
all,
17+
// For backward compatibility
18+
'flat/base': base,
19+
'flat/recommended': recommended,
20+
'flat/prettier': prettier,
21+
'flat/all': all
22+
};
23+
24+
export const rules = ruleList.reduce(
25+
(obj, r) => {
26+
obj[r.meta.docs.ruleName] = r;
27+
return obj;
28+
},
29+
{} as { [key: string]: RuleModule }
30+
) as unknown as Record<string, Rule.RuleModule>;
31+
32+
export const meta = { ...metaModule };
33+
export const processors = {
34+
'.svelte': processor,
35+
svelte: processor
36+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// IMPORTANT!
2+
// This file has been automatically generated,
3+
// in order to update its content execute "pnpm run update"
4+
//
5+
// Replace type information to use "@typescript-eslint/types" instead of "estree".
6+
//
7+
declare module 'estree' {
8+
import type { TSESTree } from '@typescript-eslint/types';
9+
10+
export type Node = TSESTree.Node;
11+
export type Program = TSESTree.Program;
12+
export type Expression = TSESTree.Expression;
13+
export type Statement = TSESTree.Statement;
14+
export type Pattern = TSESTree.DestructuringPattern;
15+
export type AccessorProperty = TSESTree.AccessorProperty;
16+
export type ArrayExpression = TSESTree.ArrayExpression;
17+
export type ArrayPattern = TSESTree.ArrayPattern;
18+
export type ArrowFunctionExpression = TSESTree.ArrowFunctionExpression;
19+
export type AssignmentExpression = TSESTree.AssignmentExpression;
20+
export type AssignmentPattern = TSESTree.AssignmentPattern;
21+
export type AwaitExpression = TSESTree.AwaitExpression;
22+
export type BinaryExpression = TSESTree.BinaryExpression;
23+
export type BlockStatement = TSESTree.BlockStatement;
24+
export type BreakStatement = TSESTree.BreakStatement;
25+
export type CallExpression = TSESTree.CallExpression;
26+
export type CatchClause = TSESTree.CatchClause;
27+
export type ChainExpression = TSESTree.ChainExpression;
28+
export type ClassBody = TSESTree.ClassBody;
29+
export type ClassDeclaration = TSESTree.ClassDeclaration;
30+
export type ClassExpression = TSESTree.ClassExpression;
31+
export type ConditionalExpression = TSESTree.ConditionalExpression;
32+
export type ContinueStatement = TSESTree.ContinueStatement;
33+
export type DebuggerStatement = TSESTree.DebuggerStatement;
34+
export type DoWhileStatement = TSESTree.DoWhileStatement;
35+
export type EmptyStatement = TSESTree.EmptyStatement;
36+
export type ExportAllDeclaration = TSESTree.ExportAllDeclaration;
37+
export type ExportDefaultDeclaration = TSESTree.ExportDefaultDeclaration;
38+
export type ExportNamedDeclaration = TSESTree.ExportNamedDeclaration;
39+
export type ExportSpecifier = TSESTree.ExportSpecifier;
40+
export type ExpressionStatement = TSESTree.ExpressionStatement;
41+
export type ForInStatement = TSESTree.ForInStatement;
42+
export type ForOfStatement = TSESTree.ForOfStatement;
43+
export type ForStatement = TSESTree.ForStatement;
44+
export type FunctionDeclaration = TSESTree.FunctionDeclaration;
45+
export type FunctionExpression = TSESTree.FunctionExpression;
46+
export type Identifier = TSESTree.Identifier;
47+
export type IfStatement = TSESTree.IfStatement;
48+
export type ImportDeclaration = TSESTree.ImportDeclaration;
49+
export type ImportDefaultSpecifier = TSESTree.ImportDefaultSpecifier;
50+
export type ImportExpression = TSESTree.ImportExpression;
51+
export type ImportNamespaceSpecifier = TSESTree.ImportNamespaceSpecifier;
52+
export type ImportSpecifier = TSESTree.ImportSpecifier;
53+
export type LabeledStatement = TSESTree.LabeledStatement;
54+
export type Literal = TSESTree.Literal;
55+
export type LogicalExpression = TSESTree.LogicalExpression;
56+
export type MemberExpression = TSESTree.MemberExpression;
57+
export type MetaProperty = TSESTree.MetaProperty;
58+
export type MethodDefinition = TSESTree.MethodDefinition;
59+
export type NewExpression = TSESTree.NewExpression;
60+
export type ObjectExpression = TSESTree.ObjectExpression;
61+
export type ObjectPattern = TSESTree.ObjectPattern;
62+
export type PrivateIdentifier = TSESTree.PrivateIdentifier;
63+
export type Property = TSESTree.Property;
64+
export type PropertyDefinition = TSESTree.PropertyDefinition;
65+
export type RestElement = TSESTree.RestElement;
66+
export type ReturnStatement = TSESTree.ReturnStatement;
67+
export type SequenceExpression = TSESTree.SequenceExpression;
68+
export type SpreadElement = TSESTree.SpreadElement;
69+
export type Super = TSESTree.Super;
70+
export type SwitchCase = TSESTree.SwitchCase;
71+
export type SwitchStatement = TSESTree.SwitchStatement;
72+
export type TaggedTemplateExpression = TSESTree.TaggedTemplateExpression;
73+
export type TemplateElement = TSESTree.TemplateElement;
74+
export type TemplateLiteral = TSESTree.TemplateLiteral;
75+
export type ThisExpression = TSESTree.ThisExpression;
76+
export type ThrowStatement = TSESTree.ThrowStatement;
77+
export type TryStatement = TSESTree.TryStatement;
78+
export type UnaryExpression = TSESTree.UnaryExpression;
79+
export type UpdateExpression = TSESTree.UpdateExpression;
80+
export type VariableDeclaration = TSESTree.VariableDeclaration;
81+
export type VariableDeclarator = TSESTree.VariableDeclarator;
82+
export type WhileStatement = TSESTree.WhileStatement;
83+
export type WithStatement = TSESTree.WithStatement;
84+
export type YieldExpression = TSESTree.YieldExpression;
85+
}

packages/eslint-plugin-svelte/tools/update-types-for-node.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const __dirname = path.dirname(new URL(import.meta.url).pathname);
99
// const filename = fileURLToPath(import.meta.url)
1010
const dirname = __dirname; // path.dirname(filename)
1111
const typesForNodeFilename = path.join(dirname, '../src/types-for-node.ts');
12-
const estreeFilename = path.join(dirname, '../typings/estree/index.d.ts');
12+
const estreeFilename = path.join(dirname, '../src/type-defs/estree.d.ts');
1313
const { visitorKeys } = parseForESLint('');
1414

1515
const esNextNodeNames = ['Decorator', 'ImportAttribute', 'StaticBlock'];
@@ -32,7 +32,7 @@ const estreeCode = [
3232
//
3333
// Replace type information to use "@typescript-eslint/types" instead of "estree".
3434
//
35-
35+
declare module 'estree' {
3636
import type { TSESTree } from "@typescript-eslint/types"
3737
3838
export type Node = TSESTree.Node
@@ -112,5 +112,6 @@ for (const nodeType of svelteNodeNames.filter((k) => !esSvelteNodeNames.includes
112112
}
113113
typesForNodeCode.push(`}`);
114114

115+
estreeCode.push(`}`);
115116
void writeAndFormat(typesForNodeFilename, typesForNodeCode.join('\n'));
116117
void writeAndFormat(estreeFilename, estreeCode.join('\n'));

packages/eslint-plugin-svelte/tsconfig.json

-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
"baseUrl": ".",
1818
"esModuleInterop": true,
1919
"outDir": "lib",
20-
"paths": {
21-
"*": ["typings/*"]
22-
},
2320
"skipLibCheck": true,
2421
"resolveJsonModule": true
2522
},
@@ -30,7 +27,6 @@
3027
"tools/**/*",
3128
"vite.config.mts",
3229
"docs-svelte-kit/**/*.mts"
33-
// "typings/**/*"
3430
],
3531
"exclude": ["lib/**/*", "tests/fixtures/**/*"]
3632
}

packages/eslint-plugin-svelte/typings/estree/index.d.ts

-84
This file was deleted.

0 commit comments

Comments
 (0)