2020-07-02 10:40:34 +02:00
|
|
|
|
|
|
|
//===
|
|
|
|
// VARIABLES
|
|
|
|
//===
|
2020-07-02 14:42:59 +02:00
|
|
|
const EVENTS = ['i-click', 'i-view', 'i-scroll-up', 'i-scroll-down', 'i-hover'];
|
|
|
|
const FUNCTION_TREE = {
|
|
|
|
'class': ['add', 'remove', 'toggle']
|
|
|
|
};
|
2020-07-02 10:40:34 +02:00
|
|
|
|
|
|
|
//===
|
|
|
|
// FUNCTIONS
|
|
|
|
//===
|
|
|
|
function validateSyntax() {
|
|
|
|
|
|
|
|
// Get every items from EVENTS
|
|
|
|
|
|
|
|
// Check all event syntax
|
|
|
|
return EVENTS.map((event) => {
|
2020-07-02 14:42:59 +02:00
|
|
|
// Check element FUNCTION_TREE
|
2020-07-02 10:40:34 +02:00
|
|
|
return R.map((element) => {
|
2020-07-02 14:42:59 +02:00
|
|
|
// Check KEY FUNCTION_TREE
|
|
|
|
return R.map((key) => {
|
|
|
|
// Check METHODS FUNCTION_TREE
|
|
|
|
return R.map((method) => {
|
|
|
|
return RegExp(`^${key}:${method}\\('\\w+', *'[#,.,a-zA-Z]\\w*'\\)$`).test(element.getAttribute(event));
|
|
|
|
}, FUNCTION_TREE[key]).some(method => method);
|
|
|
|
}, Object.keys(FUNCTION_TREE)).every(key => key);
|
2020-07-02 10:40:34 +02:00
|
|
|
}, document.querySelectorAll(`[${event}]`)).every(item => item);
|
|
|
|
}).every(event => event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===
|
|
|
|
// LINTER
|
|
|
|
//===
|
|
|
|
|
|
|
|
|
|
|
|
//===
|
|
|
|
// INIT
|
|
|
|
//===
|
2020-07-02 14:42:59 +02:00
|
|
|
console.log("EStabien " + validateSyntax());
|