open-vault/ui/.template-lintrc.js

59 lines
1.8 KiB
JavaScript

'use strict';
const fs = require('fs');
let testOverrides = {};
try {
// ember-template-lint no longer exports anything so we cannot access the rule definitions conventionally
// read file, convert to json string and parse
const toJSON = (str) => {
return JSON.parse(
str
.slice(str.indexOf(':') + 2) // get rid of export statement
.slice(0, -(str.length - str.lastIndexOf(','))) // remove trailing brackets from export
.replace(/:.*,/g, `: ${false},`) // convert values to false
.replace(/,([^,]*)$/, '$1') // remove last comma
.replace(/'/g, '"') // convert to double quotes
.replace(/(\w[^"].*[^"]):/g, '"$1":') // wrap quotes around single word keys
.trim()
);
};
const recommended = toJSON(
fs.readFileSync('node_modules/ember-template-lint/lib/config/recommended.js').toString()
);
const stylistic = toJSON(
fs.readFileSync('node_modules/ember-template-lint/lib/config/stylistic.js').toString()
);
testOverrides = {
...recommended,
...stylistic,
prettier: false,
};
} catch (error) {
console.log(error);
}
module.exports = {
plugins: ['ember-template-lint-plugin-prettier'],
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
rules: {
'no-bare-strings': 'off',
'no-action': 'off',
'no-duplicate-landmark-elements': 'warn',
'no-implicit-this': {
allow: ['supported-auth-backends'],
},
'require-input-label': 'off',
'no-down-event-binding': 'warn',
'self-closing-void-elements': 'off',
},
ignore: ['lib/story-md', 'tests/**'],
// ember language server vscode extension does not currently respect the ignore field
// override all rules manually as workaround to align with cli
overrides: [
{
files: ['**/*-test.js'],
rules: testOverrides,
},
],
};