next-a11y 0.1.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 +161 -0
- package/bin/cli.js +2 -0
- package/dist/chunk-PE4WYXR5.mjs +50 -0
- package/dist/cli/index.d.mts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2183 -0
- package/dist/cli/index.mjs +2124 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +34 -0
- package/dist/index.mjs +6 -0
- package/package.json +60 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
|
|
3
|
+
type RuleId = "img-alt" | "button-label" | "link-label" | "input-label" | "html-lang" | "emoji-alt" | "no-positive-tabindex" | "button-type" | "link-noopener" | "next-metadata-title" | "next-image-sizes" | "next-link-no-nested-a" | "next-skip-nav" | "heading-order" | "no-div-interactive";
|
|
4
|
+
type RuleSetting = "fix" | "warn" | "off";
|
|
5
|
+
type RuleType = "ai" | "deterministic" | "detect";
|
|
6
|
+
type FixType = "insert-attr" | "replace-attr" | "insert-element" | "wrap-element" | "remove-element";
|
|
7
|
+
interface Fix {
|
|
8
|
+
type: FixType;
|
|
9
|
+
attribute?: string;
|
|
10
|
+
value: string | (() => Promise<string>);
|
|
11
|
+
}
|
|
12
|
+
interface Violation {
|
|
13
|
+
rule: RuleId;
|
|
14
|
+
filePath: string;
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
element: string;
|
|
18
|
+
message: string;
|
|
19
|
+
fix?: Fix;
|
|
20
|
+
}
|
|
21
|
+
interface Rule {
|
|
22
|
+
id: RuleId;
|
|
23
|
+
type: RuleType;
|
|
24
|
+
scan(file: SourceFile): Violation[];
|
|
25
|
+
}
|
|
26
|
+
interface ScanResult {
|
|
27
|
+
violations: Violation[];
|
|
28
|
+
filesScanned: number;
|
|
29
|
+
elementsScanned: number;
|
|
30
|
+
score: number;
|
|
31
|
+
previousScore?: number;
|
|
32
|
+
fixedCount: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type ProviderName = "openai" | "anthropic" | "google" | "ollama";
|
|
36
|
+
interface A11yConfig {
|
|
37
|
+
provider?: ProviderName;
|
|
38
|
+
model?: string;
|
|
39
|
+
locale?: string;
|
|
40
|
+
cache?: string;
|
|
41
|
+
scanner?: {
|
|
42
|
+
include?: string[];
|
|
43
|
+
exclude?: string[];
|
|
44
|
+
};
|
|
45
|
+
rules?: Partial<Record<RuleId, RuleSetting>>;
|
|
46
|
+
}
|
|
47
|
+
interface ResolvedConfig {
|
|
48
|
+
provider: ProviderName | undefined;
|
|
49
|
+
model: string;
|
|
50
|
+
locale: string;
|
|
51
|
+
cache: string;
|
|
52
|
+
scanner: {
|
|
53
|
+
include: string[];
|
|
54
|
+
exclude: string[];
|
|
55
|
+
};
|
|
56
|
+
rules: Record<RuleId, RuleSetting>;
|
|
57
|
+
fix: boolean;
|
|
58
|
+
interactive: boolean;
|
|
59
|
+
noAi: boolean;
|
|
60
|
+
minScore?: number;
|
|
61
|
+
}
|
|
62
|
+
declare function defineConfig(config: A11yConfig): A11yConfig;
|
|
63
|
+
|
|
64
|
+
export { type A11yConfig, type Fix, type FixType, type ProviderName, type ResolvedConfig, type Rule, type RuleId, type RuleSetting, type RuleType, type ScanResult, type Violation, defineConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
|
|
3
|
+
type RuleId = "img-alt" | "button-label" | "link-label" | "input-label" | "html-lang" | "emoji-alt" | "no-positive-tabindex" | "button-type" | "link-noopener" | "next-metadata-title" | "next-image-sizes" | "next-link-no-nested-a" | "next-skip-nav" | "heading-order" | "no-div-interactive";
|
|
4
|
+
type RuleSetting = "fix" | "warn" | "off";
|
|
5
|
+
type RuleType = "ai" | "deterministic" | "detect";
|
|
6
|
+
type FixType = "insert-attr" | "replace-attr" | "insert-element" | "wrap-element" | "remove-element";
|
|
7
|
+
interface Fix {
|
|
8
|
+
type: FixType;
|
|
9
|
+
attribute?: string;
|
|
10
|
+
value: string | (() => Promise<string>);
|
|
11
|
+
}
|
|
12
|
+
interface Violation {
|
|
13
|
+
rule: RuleId;
|
|
14
|
+
filePath: string;
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
element: string;
|
|
18
|
+
message: string;
|
|
19
|
+
fix?: Fix;
|
|
20
|
+
}
|
|
21
|
+
interface Rule {
|
|
22
|
+
id: RuleId;
|
|
23
|
+
type: RuleType;
|
|
24
|
+
scan(file: SourceFile): Violation[];
|
|
25
|
+
}
|
|
26
|
+
interface ScanResult {
|
|
27
|
+
violations: Violation[];
|
|
28
|
+
filesScanned: number;
|
|
29
|
+
elementsScanned: number;
|
|
30
|
+
score: number;
|
|
31
|
+
previousScore?: number;
|
|
32
|
+
fixedCount: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type ProviderName = "openai" | "anthropic" | "google" | "ollama";
|
|
36
|
+
interface A11yConfig {
|
|
37
|
+
provider?: ProviderName;
|
|
38
|
+
model?: string;
|
|
39
|
+
locale?: string;
|
|
40
|
+
cache?: string;
|
|
41
|
+
scanner?: {
|
|
42
|
+
include?: string[];
|
|
43
|
+
exclude?: string[];
|
|
44
|
+
};
|
|
45
|
+
rules?: Partial<Record<RuleId, RuleSetting>>;
|
|
46
|
+
}
|
|
47
|
+
interface ResolvedConfig {
|
|
48
|
+
provider: ProviderName | undefined;
|
|
49
|
+
model: string;
|
|
50
|
+
locale: string;
|
|
51
|
+
cache: string;
|
|
52
|
+
scanner: {
|
|
53
|
+
include: string[];
|
|
54
|
+
exclude: string[];
|
|
55
|
+
};
|
|
56
|
+
rules: Record<RuleId, RuleSetting>;
|
|
57
|
+
fix: boolean;
|
|
58
|
+
interactive: boolean;
|
|
59
|
+
noAi: boolean;
|
|
60
|
+
minScore?: number;
|
|
61
|
+
}
|
|
62
|
+
declare function defineConfig(config: A11yConfig): A11yConfig;
|
|
63
|
+
|
|
64
|
+
export { type A11yConfig, type Fix, type FixType, type ProviderName, type ResolvedConfig, type Rule, type RuleId, type RuleSetting, type RuleType, type ScanResult, type Violation, defineConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
defineConfig: () => defineConfig
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/config/schema.ts
|
|
28
|
+
function defineConfig(config) {
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
defineConfig
|
|
34
|
+
});
|
package/dist/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-a11y",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AI-powered accessibility codemod for Next.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"next-a11y": "./bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"bin"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup",
|
|
24
|
+
"dev": "tsup --watch",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"next",
|
|
30
|
+
"nextjs",
|
|
31
|
+
"a11y",
|
|
32
|
+
"accessibility",
|
|
33
|
+
"wcag",
|
|
34
|
+
"codemod"
|
|
35
|
+
],
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"ai": "^4.0.0",
|
|
39
|
+
"ts-morph": "^24.0.0",
|
|
40
|
+
"commander": "^12.0.0",
|
|
41
|
+
"picocolors": "^1.1.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tsup": "^8.0.0",
|
|
45
|
+
"typescript": "^5.0.0",
|
|
46
|
+
"vitest": "^2.0.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@ai-sdk/openai": ">=1.0.0",
|
|
50
|
+
"@ai-sdk/anthropic": ">=1.0.0",
|
|
51
|
+
"@ai-sdk/google": ">=1.0.0",
|
|
52
|
+
"ollama-ai-provider": ">=1.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@ai-sdk/openai": { "optional": true },
|
|
56
|
+
"@ai-sdk/anthropic": { "optional": true },
|
|
57
|
+
"@ai-sdk/google": { "optional": true },
|
|
58
|
+
"ollama-ai-provider": { "optional": true }
|
|
59
|
+
}
|
|
60
|
+
}
|