eslint-plugin-svg 0.0.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/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/index.cjs +89 -0
- package/dist/index.d.cts +57 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +57 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-PRESENT ntnyq <https://github.com/ntnyq>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# eslint-plugin-svg
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ntnyq/eslint-plugin-svg/actions)
|
|
4
|
+
[](https://www.npmjs.com/package/eslint-plugin-svg)
|
|
5
|
+
[](https://www.npmjs.com/package/eslint-plugin-svg)
|
|
6
|
+
[](https://codecov.io/github/ntnyq/eslint-plugin-svg)
|
|
7
|
+
[](https://github.com/ntnyq/eslint-plugin-svg/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
> Rules for consistent, readable and valid SVG files.
|
|
10
|
+
|
|
11
|
+
> [!WARNING]
|
|
12
|
+
> This plugin is Work In Progress. API may change at every release. Please use with caution.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install eslint-plugin-svg -D
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add eslint-plugin-svg -D
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add eslint-plugin-svg -D
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Config in ESLint config files:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import pluginSvg from 'eslint-plugin-svg'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @type {import('eslint').Linter.Config[]}
|
|
37
|
+
*/
|
|
38
|
+
export default [
|
|
39
|
+
...pluginSvg.configs.recommended,
|
|
40
|
+
// Other configs...
|
|
41
|
+
]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
:apple: For advanced usaged, please check [Advanced Usage](https://eslint-plugin-svg.ntnyq.com/guide/#advanced-usage)
|
|
45
|
+
|
|
46
|
+
## Rules
|
|
47
|
+
|
|
48
|
+
💼 Configurations enabled in.\
|
|
49
|
+
✅ Set in the `recommended` preset.\
|
|
50
|
+
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
|
|
51
|
+
💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
|
|
52
|
+
|
|
53
|
+
| Name | Description | 💼 | 🔧 | 💡 |
|
|
54
|
+
| :--- | :---------- | :-: | :-: | :-: |
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
[MIT](./LICENSE) License © 2024-PRESENT [ntnyq](https://github.com/ntnyq)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
configs: () => configs,
|
|
24
|
+
createRecommendedConfig: () => createRecommendedConfig,
|
|
25
|
+
default: () => src_default,
|
|
26
|
+
meta: () => meta,
|
|
27
|
+
plugin: () => plugin,
|
|
28
|
+
recommended: () => recommended,
|
|
29
|
+
rules: () => rules
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/configs/index.ts
|
|
34
|
+
function createRecommendedConfig(options = {}) {
|
|
35
|
+
const config = {
|
|
36
|
+
...options,
|
|
37
|
+
// Overrides
|
|
38
|
+
name: options.name || "svg/recommended",
|
|
39
|
+
files: options.files || ["**/*.svg"],
|
|
40
|
+
ignores: options.ignores || [],
|
|
41
|
+
languageOptions: options.languageOptions,
|
|
42
|
+
plugins: {
|
|
43
|
+
...options.plugins || {},
|
|
44
|
+
/* v8 ignore start */
|
|
45
|
+
get svg() {
|
|
46
|
+
return plugin;
|
|
47
|
+
}
|
|
48
|
+
/* v8 ignore stop */
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
...options.overridesRules || {}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
56
|
+
var recommended = [
|
|
57
|
+
// flat recommended config
|
|
58
|
+
createRecommendedConfig()
|
|
59
|
+
];
|
|
60
|
+
var configs = {
|
|
61
|
+
recommended
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// src/meta.ts
|
|
65
|
+
var meta = {
|
|
66
|
+
name: "eslint-plugin-svg",
|
|
67
|
+
version: "0.0.0"
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/rules/index.ts
|
|
71
|
+
var rules = {};
|
|
72
|
+
|
|
73
|
+
// src/index.ts
|
|
74
|
+
var plugin = {
|
|
75
|
+
meta,
|
|
76
|
+
// FIXME: type not match
|
|
77
|
+
rules,
|
|
78
|
+
configs
|
|
79
|
+
};
|
|
80
|
+
var src_default = plugin;
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
configs,
|
|
84
|
+
createRecommendedConfig,
|
|
85
|
+
meta,
|
|
86
|
+
plugin,
|
|
87
|
+
recommended,
|
|
88
|
+
rules
|
|
89
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
import { Linter, Rule } from 'eslint';
|
|
3
|
+
|
|
4
|
+
declare const rules: {};
|
|
5
|
+
|
|
6
|
+
type RuleDefinitions = typeof rules;
|
|
7
|
+
type RuleOptions = {
|
|
8
|
+
[K in keyof RuleDefinitions]: RuleDefinitions[K]['defaultOptions'];
|
|
9
|
+
};
|
|
10
|
+
type Rules = {
|
|
11
|
+
[K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]>;
|
|
12
|
+
};
|
|
13
|
+
type RulesWithPluginName<Name extends string = 'svg'> = {
|
|
14
|
+
[K in keyof RuleOptions as `${Name}/${K}`]: Linter.RuleEntry<RuleOptions[K]>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare const meta: {
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
interface RecommendedOptions extends Linter.Config {
|
|
23
|
+
/**
|
|
24
|
+
* Overrides rules.
|
|
25
|
+
*/
|
|
26
|
+
overridesRules?: RulesWithPluginName;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create recommended config in flat style.
|
|
30
|
+
*
|
|
31
|
+
* @param options - Create recommended config {@link RecommendedOptions}.
|
|
32
|
+
* @returns flat recommended config.
|
|
33
|
+
*/
|
|
34
|
+
declare function createRecommendedConfig(options?: RecommendedOptions): Linter.Config<Linter.RulesRecord>;
|
|
35
|
+
declare const recommended: Linter.Config<Linter.RulesRecord>[];
|
|
36
|
+
declare const configs: {
|
|
37
|
+
recommended: Linter.Config<Linter.RulesRecord>[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* eslint-plugin-svg
|
|
42
|
+
* Rules for consistent, readable and valid SVG files.
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://github.com/ntnyq/eslint-plugin-svg}
|
|
45
|
+
*/
|
|
46
|
+
declare const plugin: {
|
|
47
|
+
meta: {
|
|
48
|
+
name: string;
|
|
49
|
+
version: string;
|
|
50
|
+
};
|
|
51
|
+
rules: Record<string, Rule.RuleModule>;
|
|
52
|
+
configs: {
|
|
53
|
+
recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { type RecommendedOptions, type RuleOptions, type Rules, type RulesWithPluginName, configs, createRecommendedConfig, plugin as default, meta, plugin, recommended, rules };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as eslint from 'eslint';
|
|
2
|
+
import { Linter, Rule } from 'eslint';
|
|
3
|
+
|
|
4
|
+
declare const rules: {};
|
|
5
|
+
|
|
6
|
+
type RuleDefinitions = typeof rules;
|
|
7
|
+
type RuleOptions = {
|
|
8
|
+
[K in keyof RuleDefinitions]: RuleDefinitions[K]['defaultOptions'];
|
|
9
|
+
};
|
|
10
|
+
type Rules = {
|
|
11
|
+
[K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]>;
|
|
12
|
+
};
|
|
13
|
+
type RulesWithPluginName<Name extends string = 'svg'> = {
|
|
14
|
+
[K in keyof RuleOptions as `${Name}/${K}`]: Linter.RuleEntry<RuleOptions[K]>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare const meta: {
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
interface RecommendedOptions extends Linter.Config {
|
|
23
|
+
/**
|
|
24
|
+
* Overrides rules.
|
|
25
|
+
*/
|
|
26
|
+
overridesRules?: RulesWithPluginName;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create recommended config in flat style.
|
|
30
|
+
*
|
|
31
|
+
* @param options - Create recommended config {@link RecommendedOptions}.
|
|
32
|
+
* @returns flat recommended config.
|
|
33
|
+
*/
|
|
34
|
+
declare function createRecommendedConfig(options?: RecommendedOptions): Linter.Config<Linter.RulesRecord>;
|
|
35
|
+
declare const recommended: Linter.Config<Linter.RulesRecord>[];
|
|
36
|
+
declare const configs: {
|
|
37
|
+
recommended: Linter.Config<Linter.RulesRecord>[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* eslint-plugin-svg
|
|
42
|
+
* Rules for consistent, readable and valid SVG files.
|
|
43
|
+
*
|
|
44
|
+
* @see {@link https://github.com/ntnyq/eslint-plugin-svg}
|
|
45
|
+
*/
|
|
46
|
+
declare const plugin: {
|
|
47
|
+
meta: {
|
|
48
|
+
name: string;
|
|
49
|
+
version: string;
|
|
50
|
+
};
|
|
51
|
+
rules: Record<string, Rule.RuleModule>;
|
|
52
|
+
configs: {
|
|
53
|
+
recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { type RecommendedOptions, type RuleOptions, type Rules, type RulesWithPluginName, configs, createRecommendedConfig, plugin as default, meta, plugin, recommended, rules };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/configs/index.ts
|
|
2
|
+
function createRecommendedConfig(options = {}) {
|
|
3
|
+
const config = {
|
|
4
|
+
...options,
|
|
5
|
+
// Overrides
|
|
6
|
+
name: options.name || "svg/recommended",
|
|
7
|
+
files: options.files || ["**/*.svg"],
|
|
8
|
+
ignores: options.ignores || [],
|
|
9
|
+
languageOptions: options.languageOptions,
|
|
10
|
+
plugins: {
|
|
11
|
+
...options.plugins || {},
|
|
12
|
+
/* v8 ignore start */
|
|
13
|
+
get svg() {
|
|
14
|
+
return plugin;
|
|
15
|
+
}
|
|
16
|
+
/* v8 ignore stop */
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
...options.overridesRules || {}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
var recommended = [
|
|
25
|
+
// flat recommended config
|
|
26
|
+
createRecommendedConfig()
|
|
27
|
+
];
|
|
28
|
+
var configs = {
|
|
29
|
+
recommended
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/meta.ts
|
|
33
|
+
var meta = {
|
|
34
|
+
name: "eslint-plugin-svg",
|
|
35
|
+
version: "0.0.0"
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/rules/index.ts
|
|
39
|
+
var rules = {};
|
|
40
|
+
|
|
41
|
+
// src/index.ts
|
|
42
|
+
var plugin = {
|
|
43
|
+
meta,
|
|
44
|
+
// FIXME: type not match
|
|
45
|
+
rules,
|
|
46
|
+
configs
|
|
47
|
+
};
|
|
48
|
+
var src_default = plugin;
|
|
49
|
+
export {
|
|
50
|
+
configs,
|
|
51
|
+
createRecommendedConfig,
|
|
52
|
+
src_default as default,
|
|
53
|
+
meta,
|
|
54
|
+
plugin,
|
|
55
|
+
recommended,
|
|
56
|
+
rules
|
|
57
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-svg",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "Rules for consistent, readable and valid SVG files.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"eslint",
|
|
8
|
+
"eslint-plugin",
|
|
9
|
+
"svg"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "ntnyq",
|
|
14
|
+
"email": "ntnyq13@gmail.com"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/ntnyq/eslint-plugin-svg#readme",
|
|
17
|
+
"repository": "ntnyq/eslint-plugin-svg",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/ntnyq/eslint-plugin-svg/issues"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": "./package.json",
|
|
23
|
+
".": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"eslint": "^9.5.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@ntnyq/utils": "^0.4.1",
|
|
45
|
+
"@types/json-schema": "^7.0.15"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@ntnyq/eslint-config": "^3.9.0",
|
|
49
|
+
"@ntnyq/prettier-config": "^1.22.0",
|
|
50
|
+
"@types/node": "^22.10.1",
|
|
51
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
52
|
+
"bumpp": "^9.8.1",
|
|
53
|
+
"eslint": "^9.16.0",
|
|
54
|
+
"eslint-plugin-eslint-plugin": "^6.3.2",
|
|
55
|
+
"eslint-vitest-rule-tester": "^0.7.0",
|
|
56
|
+
"husky": "^9.1.7",
|
|
57
|
+
"nano-staged": "^0.8.0",
|
|
58
|
+
"npm-run-all2": "^7.0.1",
|
|
59
|
+
"prettier": "^3.4.2",
|
|
60
|
+
"tinyglobby": "^0.2.10",
|
|
61
|
+
"tsup": "^8.3.5",
|
|
62
|
+
"tsx": "^4.19.2",
|
|
63
|
+
"typescript": "^5.7.2",
|
|
64
|
+
"vitest": "^2.1.8"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
68
|
+
},
|
|
69
|
+
"nano-staged": {
|
|
70
|
+
"*.{js,ts,mjs,cjs,vue,json,md,yml,yaml}": "eslint --fix"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsup",
|
|
74
|
+
"coverage": "vitest --coverage",
|
|
75
|
+
"deploy": "run-s build docs:build",
|
|
76
|
+
"dev": "tsup --watch src",
|
|
77
|
+
"docs:build": "pnpm -C docs run build",
|
|
78
|
+
"docs:dev": "pnpm -C docs run dev",
|
|
79
|
+
"lint": "eslint .",
|
|
80
|
+
"release": "run-s release:check release:publish",
|
|
81
|
+
"release:check": "run-s lint typecheck test",
|
|
82
|
+
"release:publish": "bumpp && pnpm publish",
|
|
83
|
+
"test": "vitest",
|
|
84
|
+
"typecheck": "tsc --noEmit"
|
|
85
|
+
}
|
|
86
|
+
}
|