@sa11y/preset-rules
Advanced tools
Comparing version 6.9.0 to 6.9.1
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -36,29 +13,18 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
const fs = __importStar(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const axe_core_1 = __importDefault(require("axe-core")); | ||
const common_1 = require("@sa11y/common"); | ||
// Directory containing custom rules and checks | ||
const customRulesPathDir = 'custom-rules'; | ||
const checks_1 = __importDefault(require("./custom-rules/checks")); | ||
const rules_1 = __importDefault(require("./custom-rules/rules")); | ||
const changes_1 = __importDefault(require("./custom-rules/changes")); | ||
function registerCustomRules() { | ||
const directoryPath = path_1.default.join(__dirname, customRulesPathDir); | ||
const newChecks = []; | ||
const newRules = []; | ||
try { | ||
// Path to the JSON file with changes to existing rules | ||
const changesInExistingRulesPath = path_1.default.join(directoryPath, 'changes.json'); | ||
// Read and parse existing rule changes | ||
const existingRuleData = fs.readFileSync(changesInExistingRulesPath, 'utf-8'); | ||
const { rules } = JSON.parse(existingRuleData); | ||
if (rules && Array.isArray(rules)) { | ||
newRules.push(...rules); | ||
} | ||
// Process checks and rules JSON files | ||
(0, common_1.processFiles)(path_1.default.join(directoryPath, 'checks'), newChecks, '.json', JSON.parse); | ||
(0, common_1.processFiles)(path_1.default.join(directoryPath, 'rules'), newRules, '.json', JSON.parse); | ||
// Read and parse existing rule changes | ||
const { rules } = changes_1.default; | ||
const newRulesData = rules_1.default; | ||
const newChecksData = checks_1.default; | ||
if (rules && Array.isArray(rules)) { | ||
newRules.push(...rules); | ||
} | ||
catch (e) { | ||
const err = e; | ||
console.error('Error in reading Custom Rules files: ', err.message); | ||
} | ||
newRules.push(...newRulesData); | ||
newChecks.push(...newChecksData); | ||
// Configure axe with the new checks and rules | ||
@@ -65,0 +31,0 @@ const spec = { rules: newRules, checks: newChecks }; |
{ | ||
"name": "@sa11y/preset-rules", | ||
"version": "6.9.0", | ||
"version": "6.9.1", | ||
"description": "Accessibility preset rule configs for axe", | ||
@@ -24,7 +24,4 @@ "license": "BSD-3-Clause", | ||
"dependencies": { | ||
"@sa11y/common": "6.9.0" | ||
"@sa11y/common": "6.9.1" | ||
}, | ||
"scripts": { | ||
"copy-json": "cpx 'src/**/*.json' dist" | ||
}, | ||
"devDependencies": { | ||
@@ -41,3 +38,3 @@ "@jest/globals": "28.1.3", | ||
}, | ||
"gitHead": "90bd6111dfe1bec4ff98d5e1527a245c3c0a5498" | ||
"gitHead": "a953b9b6e8a49bb8d1af366e71cd82d573ad7b03" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74174
39
596
3
+ Added@sa11y/common@6.9.1(transitive)
- Removed@sa11y/common@6.9.0(transitive)
Updated@sa11y/common@6.9.1