eslint-plugin-svelte 2.43.0 → 2.44.0

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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `eslint-plugin-svelte` is the official [ESLint] plugin for [Svelte].
4
4
  It provides many unique check rules by using the template AST.
5
- You can check on the [Online DEMO](https://sveltejs.github.io/eslint-plugin-svelte/playground/).
5
+ You can check on the [Online DEMO](https://eslint-online-playground.netlify.app/#eslint-plugin-svelte%20with%20typescript).
6
6
 
7
7
  **_We are working on experimental support for Svelte v5, but may break with new versions of Svelte v5._**
8
8
 
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.Config;
2
+ declare const config: Linter.LegacyConfig;
3
3
  export = config;
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.Config;
2
+ declare const config: Linter.LegacyConfig;
3
3
  export = config;
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.FlatConfig[];
2
+ declare const config: Linter.Config[];
3
3
  export default config;
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.FlatConfig[];
2
+ declare const config: Linter.Config[];
3
3
  export default config;
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.FlatConfig[];
2
+ declare const config: Linter.Config[];
3
3
  export default config;
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.Config;
2
+ declare const config: Linter.LegacyConfig;
3
3
  export = config;
@@ -1,3 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
- declare const config: Linter.Config;
2
+ declare const config: Linter.LegacyConfig;
3
3
  export = config;
package/lib/index.d.ts CHANGED
@@ -4,14 +4,14 @@ import * as processor from './processor';
4
4
  declare const _default: {
5
5
  meta: typeof processor.meta;
6
6
  configs: {
7
- base: import("eslint").Linter.Config<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
8
- recommended: import("eslint").Linter.Config<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
9
- prettier: import("eslint").Linter.Config<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
10
- all: import("eslint").Linter.Config<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
11
- 'flat/base': import("eslint").Linter.FlatConfig<import("eslint").Linter.RulesRecord>[];
12
- 'flat/recommended': import("eslint").Linter.FlatConfig<import("eslint").Linter.RulesRecord>[];
13
- 'flat/prettier': import("eslint").Linter.FlatConfig<import("eslint").Linter.RulesRecord>[];
14
- 'flat/all': import("eslint").Linter.FlatConfig<import("eslint").Linter.RulesRecord>[];
7
+ base: import("eslint").Linter.LegacyConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
8
+ recommended: import("eslint").Linter.LegacyConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
9
+ prettier: import("eslint").Linter.LegacyConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
10
+ all: import("eslint").Linter.LegacyConfig<import("eslint").Linter.RulesRecord, import("eslint").Linter.RulesRecord>;
11
+ 'flat/base': import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
12
+ 'flat/recommended': import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
13
+ 'flat/prettier': import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
14
+ 'flat/all': import("eslint").Linter.FlatConfig[];
15
15
  };
16
16
  rules: {
17
17
  [key: string]: RuleModule;
package/lib/meta.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const name = "eslint-plugin-svelte";
2
- export declare const version = "2.43.0";
2
+ export declare const version = "2.44.0";
package/lib/meta.js CHANGED
@@ -5,4 +5,4 @@ exports.version = exports.name = void 0;
5
5
  // This file has been automatically generated,
6
6
  // in order to update its content execute "pnpm run update"
7
7
  exports.name = 'eslint-plugin-svelte';
8
- exports.version = '2.43.0';
8
+ exports.version = '2.44.0';
@@ -375,6 +375,7 @@ type SvelteHtmlSelfClosing = [] | [
375
375
  ({
376
376
  void?: ("never" | "always" | "ignore");
377
377
  normal?: ("never" | "always" | "ignore");
378
+ foreign?: ("never" | "always" | "ignore");
378
379
  component?: ("never" | "always" | "ignore");
379
380
  svelte?: ("never" | "always" | "ignore");
380
381
  } | ("all" | "html" | "none"))
@@ -6,6 +6,7 @@ const compat_1 = require("../utils/compat");
6
6
  const TYPE_MESSAGES = {
7
7
  normal: 'HTML elements',
8
8
  void: 'HTML void elements',
9
+ foreign: 'foreign (SVG or MathML) elements',
9
10
  component: 'Svelte custom components',
10
11
  svelte: 'Svelte special elements'
11
12
  };
@@ -34,6 +35,9 @@ exports.default = (0, utils_1.createRule)('html-self-closing', {
34
35
  normal: {
35
36
  enum: ['never', 'always', 'ignore']
36
37
  },
38
+ foreign: {
39
+ enum: ['never', 'always', 'ignore']
40
+ },
37
41
  component: {
38
42
  enum: ['never', 'always', 'ignore']
39
43
  },
@@ -54,6 +58,7 @@ exports.default = (0, utils_1.createRule)('html-self-closing', {
54
58
  let options = {
55
59
  void: 'always',
56
60
  normal: 'always',
61
+ foreign: 'always',
57
62
  component: 'always',
58
63
  svelte: 'always'
59
64
  };
@@ -63,6 +68,7 @@ exports.default = (0, utils_1.createRule)('html-self-closing', {
63
68
  options = {
64
69
  void: 'never',
65
70
  normal: 'never',
71
+ foreign: 'never',
66
72
  component: 'never',
67
73
  svelte: 'never'
68
74
  };
@@ -71,6 +77,7 @@ exports.default = (0, utils_1.createRule)('html-self-closing', {
71
77
  options = {
72
78
  void: 'always',
73
79
  normal: 'never',
80
+ foreign: 'always',
74
81
  component: 'never',
75
82
  svelte: 'always'
76
83
  };
@@ -98,6 +105,8 @@ exports.default = (0, utils_1.createRule)('html-self-closing', {
98
105
  return 'svelte';
99
106
  if ((0, ast_utils_1.isVoidHtmlElement)(node))
100
107
  return 'void';
108
+ if ((0, ast_utils_1.isForeignElement)(node))
109
+ return 'foreign';
101
110
  return 'normal';
102
111
  }
103
112
  /**
@@ -101,5 +101,9 @@ export declare function getNodeName(node: SvAST.SvelteElement): string;
101
101
  * {@link https://developer.mozilla.org/en-US/docs/Glossary/Empty_element}
102
102
  */
103
103
  export declare function isVoidHtmlElement(node: SvAST.SvelteElement): boolean;
104
+ /**
105
+ * Returns true if element is known foreign (SVG or MathML) element
106
+ */
107
+ export declare function isForeignElement(node: SvAST.SvelteElement): boolean;
104
108
  /** Checks whether the given identifier node is used as an expression. */
105
109
  export declare function isExpressionIdentifier(node: TSESTree.Identifier): boolean;
@@ -22,9 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.equalTokens = equalTokens;
30
27
  exports.getStringIfConstant = getStringIfConstant;
@@ -45,9 +42,10 @@ exports.getAttributeKeyText = getAttributeKeyText;
45
42
  exports.getDirectiveName = getDirectiveName;
46
43
  exports.getNodeName = getNodeName;
47
44
  exports.isVoidHtmlElement = isVoidHtmlElement;
45
+ exports.isForeignElement = isForeignElement;
48
46
  exports.isExpressionIdentifier = isExpressionIdentifier;
49
47
  const eslintUtils = __importStar(require("@eslint-community/eslint-utils"));
50
- const void_elements_1 = __importDefault(require("./void-elements"));
48
+ const element_types_1 = require("./element-types");
51
49
  const compat_1 = require("./compat");
52
50
  /**
53
51
  * Checks whether or not the tokens of two given nodes are same.
@@ -442,7 +440,13 @@ function getNodeName(node) {
442
440
  * {@link https://developer.mozilla.org/en-US/docs/Glossary/Empty_element}
443
441
  */
444
442
  function isVoidHtmlElement(node) {
445
- return void_elements_1.default.includes(getNodeName(node));
443
+ return element_types_1.voidElements.includes(getNodeName(node));
444
+ }
445
+ /**
446
+ * Returns true if element is known foreign (SVG or MathML) element
447
+ */
448
+ function isForeignElement(node) {
449
+ return element_types_1.svgElements.includes(getNodeName(node)) || element_types_1.mathmlElements.includes(getNodeName(node));
446
450
  }
447
451
  /** Checks whether the given identifier node is used as an expression. */
448
452
  function isExpressionIdentifier(node) {
@@ -0,0 +1,3 @@
1
+ export declare const voidElements: string[];
2
+ export declare const svgElements: string[];
3
+ export declare const mathmlElements: string[];
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mathmlElements = exports.svgElements = exports.voidElements = void 0;
4
+ exports.voidElements = [
5
+ 'area',
6
+ 'base',
7
+ 'br',
8
+ 'col',
9
+ 'embed',
10
+ 'hr',
11
+ 'img',
12
+ 'input',
13
+ 'keygen',
14
+ 'link',
15
+ 'menuitem',
16
+ 'meta',
17
+ 'param',
18
+ 'source',
19
+ 'track',
20
+ 'wbr'
21
+ ];
22
+ exports.svgElements = [
23
+ 'altGlyph',
24
+ 'altGlyphDef',
25
+ 'altGlyphItem',
26
+ 'animate',
27
+ 'animateColor',
28
+ 'animateMotion',
29
+ 'animateTransform',
30
+ 'circle',
31
+ 'clipPath',
32
+ 'color-profile',
33
+ 'cursor',
34
+ 'defs',
35
+ 'desc',
36
+ 'discard',
37
+ 'ellipse',
38
+ 'feBlend',
39
+ 'feColorMatrix',
40
+ 'feComponentTransfer',
41
+ 'feComposite',
42
+ 'feConvolveMatrix',
43
+ 'feDiffuseLighting',
44
+ 'feDisplacementMap',
45
+ 'feDistantLight',
46
+ 'feDropShadow',
47
+ 'feFlood',
48
+ 'feFuncA',
49
+ 'feFuncB',
50
+ 'feFuncG',
51
+ 'feFuncR',
52
+ 'feGaussianBlur',
53
+ 'feImage',
54
+ 'feMerge',
55
+ 'feMergeNode',
56
+ 'feMorphology',
57
+ 'feOffset',
58
+ 'fePointLight',
59
+ 'feSpecularLighting',
60
+ 'feSpotLight',
61
+ 'feTile',
62
+ 'feTurbulence',
63
+ 'filter',
64
+ 'font',
65
+ 'font-face',
66
+ 'font-face-format',
67
+ 'font-face-name',
68
+ 'font-face-src',
69
+ 'font-face-uri',
70
+ 'foreignObject',
71
+ 'g',
72
+ 'glyph',
73
+ 'glyphRef',
74
+ 'hatch',
75
+ 'hatchpath',
76
+ 'hkern',
77
+ 'image',
78
+ 'line',
79
+ 'linearGradient',
80
+ 'marker',
81
+ 'mask',
82
+ 'mesh',
83
+ 'meshgradient',
84
+ 'meshpatch',
85
+ 'meshrow',
86
+ 'metadata',
87
+ 'missing-glyph',
88
+ 'mpath',
89
+ 'path',
90
+ 'pattern',
91
+ 'polygon',
92
+ 'polyline',
93
+ 'radialGradient',
94
+ 'rect',
95
+ 'set',
96
+ 'solidcolor',
97
+ 'stop',
98
+ 'svg',
99
+ 'switch',
100
+ 'symbol',
101
+ 'text',
102
+ 'textPath',
103
+ 'tref',
104
+ 'tspan',
105
+ 'unknown',
106
+ 'use',
107
+ 'view',
108
+ 'vkern'
109
+ ];
110
+ exports.mathmlElements = [
111
+ 'annotation',
112
+ 'annotation-xml',
113
+ 'maction',
114
+ 'math',
115
+ 'merror',
116
+ 'mfrac',
117
+ 'mi',
118
+ 'mmultiscripts',
119
+ 'mn',
120
+ 'mo',
121
+ 'mover',
122
+ 'mpadded',
123
+ 'mphantom',
124
+ 'mprescripts',
125
+ 'mroot',
126
+ 'mrow',
127
+ 'ms',
128
+ 'mspace',
129
+ 'msqrt',
130
+ 'mstyle',
131
+ 'msub',
132
+ 'msubsup',
133
+ 'msup',
134
+ 'mtable',
135
+ 'mtd',
136
+ 'mtext',
137
+ 'mtr',
138
+ 'munder',
139
+ 'munderover',
140
+ 'semantics'
141
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-svelte",
3
- "version": "2.43.0",
3
+ "version": "2.44.0",
4
4
  "description": "ESLint plugin for Svelte using AST",
5
5
  "repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",
6
6
  "homepage": "https://sveltejs.github.io/eslint-plugin-svelte",
@@ -22,30 +22,6 @@
22
22
  "svelte",
23
23
  "sveltejs"
24
24
  ],
25
- "scripts": {
26
- "build": "pnpm run build:meta && pnpm run build:ts",
27
- "build:meta": "pnpm run ts ./tools/update-meta.ts",
28
- "build:ts": "tsc --project ./tsconfig.build.json",
29
- "clean": "rimraf .nyc_output lib coverage build .svelte-kit svelte.config-dist.js",
30
- "cover": "nyc --reporter=lcov pnpm run test",
31
- "debug": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
32
- "lint": "run-p lint:*",
33
- "lint-fix": "pnpm run lint:es --fix && pnpm run lint:style --fix",
34
- "lint:es": "eslint --cache .",
35
- "mocha": "pnpm run ts ./node_modules/mocha/bin/mocha.js",
36
- "new": "pnpm run ts ./tools/new-rule.ts",
37
- "prebuild": "pnpm run clean",
38
- "prerelease": "pnpm run clean && pnpm run build",
39
- "release": "changeset publish",
40
- "test": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
41
- "test:debug": "env-cmd -e debug pnpm run test",
42
- "test:update-fixtures": "env-cmd -e update-fixtures pnpm run test",
43
- "ts": "node -r esbuild-register",
44
- "typecov": "type-coverage",
45
- "update": "pnpm run ts ./tools/update.ts",
46
- "version": "env-cmd -e version pnpm run update",
47
- "version:ci": "env-cmd -e version-ci pnpm run update && changeset version"
48
- },
49
25
  "peerDependencies": {
50
26
  "eslint": "^7.0.0 || ^8.0.0-0 || ^9.0.0-0",
51
27
  "svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.191"
@@ -66,42 +42,42 @@
66
42
  "postcss-safe-parser": "^6.0.0",
67
43
  "postcss-selector-parser": "^6.1.0",
68
44
  "semver": "^7.6.2",
69
- "svelte-eslint-parser": "^0.41.0"
45
+ "svelte-eslint-parser": "^0.41.1"
70
46
  },
71
47
  "devDependencies": {
72
- "@babel/core": "^7.24.7",
73
- "@babel/eslint-parser": "^7.24.7",
48
+ "@babel/core": "^7.25.2",
49
+ "@babel/eslint-parser": "^7.25.1",
74
50
  "@babel/plugin-proposal-function-bind": "^7.24.7",
75
- "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
51
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
76
52
  "@types/babel__core": "^7.20.5",
77
53
  "@types/eslint-utils": "^3.0.5",
78
54
  "@types/esutils": "^2.0.2",
79
55
  "@types/json-schema": "^7.0.15",
80
56
  "@types/less": "^3.0.6",
81
- "@types/mocha": "^10.0.6",
82
- "@types/node": "^20.14.2",
57
+ "@types/mocha": "^10.0.8",
58
+ "@types/node": "^20.16.5",
83
59
  "@types/postcss-safe-parser": "^5.0.4",
84
60
  "@types/semver": "^7.5.8",
85
61
  "@types/stylus": "^0.48.42",
86
- "acorn": "^8.12.0",
62
+ "acorn": "^8.12.1",
87
63
  "assert": "^2.1.0",
88
- "esbuild": "^0.23.0",
89
- "esbuild-register": "^3.5.0",
90
- "eslint-scope": "^8.0.1",
91
- "eslint-typegen": "^0.2.4",
64
+ "esbuild": "^0.23.1",
65
+ "esbuild-register": "^3.6.0",
66
+ "eslint-scope": "^8.0.2",
67
+ "eslint-typegen": "^0.3.2",
92
68
  "eslint-visitor-keys": "^4.0.0",
93
- "espree": "^10.0.1",
69
+ "espree": "^10.1.0",
94
70
  "less": "^4.2.0",
95
- "mocha": "^10.4.0",
71
+ "mocha": "^10.7.3",
96
72
  "nyc": "^17.0.0",
97
- "postcss-nested": "^6.0.1",
98
- "sass": "^1.77.5",
99
- "source-map-js": "^1.2.0",
73
+ "postcss-nested": "^6.2.0",
74
+ "sass": "^1.78.0",
75
+ "source-map-js": "^1.2.1",
100
76
  "stylus": "^0.63.0",
101
- "svelte": "^5.0.0-next.191",
77
+ "svelte": "5.0.0-next.245",
102
78
  "svelte-i18n": "^4.0.0",
103
- "type-coverage": "^2.29.0",
104
- "yaml": "^2.4.5"
79
+ "type-coverage": "^2.29.1",
80
+ "yaml": "^2.5.1"
105
81
  },
106
82
  "publishConfig": {
107
83
  "access": "public"
@@ -116,5 +92,29 @@
116
92
  "showRelativePath": true,
117
93
  "strict": true,
118
94
  "update": true
95
+ },
96
+ "scripts": {
97
+ "build": "pnpm run build:meta && pnpm run build:ts",
98
+ "build:meta": "pnpm run ts ./tools/update-meta.ts",
99
+ "build:ts": "tsc --project ./tsconfig.build.json",
100
+ "clean": "rimraf .nyc_output lib coverage build .svelte-kit svelte.config-dist.js",
101
+ "cover": "nyc --reporter=lcov pnpm run test",
102
+ "debug": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
103
+ "lint": "run-p lint:*",
104
+ "lint-fix": "pnpm run lint:es --fix && pnpm run lint:style --fix",
105
+ "lint:es": "eslint --cache .",
106
+ "mocha": "pnpm run ts ./node_modules/mocha/bin/mocha.js",
107
+ "new": "pnpm run ts ./tools/new-rule.ts",
108
+ "prebuild": "pnpm run clean",
109
+ "prerelease": "pnpm run clean && pnpm run build",
110
+ "release": "changeset publish",
111
+ "test": "pnpm run mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000",
112
+ "test:debug": "env-cmd -e debug pnpm run test",
113
+ "test:update-fixtures": "env-cmd -e update-fixtures pnpm run test",
114
+ "ts": "node -r esbuild-register",
115
+ "typecov": "type-coverage",
116
+ "update": "pnpm run ts ./tools/update.ts",
117
+ "version": "env-cmd -e version pnpm run update",
118
+ "version:ci": "env-cmd -e version-ci pnpm run update && changeset version"
119
119
  }
120
- }
120
+ }
@@ -1,2 +0,0 @@
1
- declare const voidElements: string[];
2
- export default voidElements;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const voidElements = [
4
- 'area',
5
- 'base',
6
- 'br',
7
- 'col',
8
- 'embed',
9
- 'hr',
10
- 'img',
11
- 'input',
12
- 'keygen',
13
- 'link',
14
- 'menuitem',
15
- 'meta',
16
- 'param',
17
- 'source',
18
- 'track',
19
- 'wbr'
20
- ];
21
- exports.default = voidElements;