Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
add detail messages to config options
Browse files Browse the repository at this point in the history
  • Loading branch information
MeirionHughes committed Jun 11, 2016
1 parent afed9a7 commit 164690f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
11 changes: 1 addition & 10 deletions source/aurelia-linter.ts
Expand Up @@ -11,16 +11,7 @@ import {TemplateRule} from './template';
import {RepeatForRule} from './repeatfor';
import {ConflictingAttributesRule} from './conflictingattributes';

export class Config {
obsoleteTags: Array<string> = ['content'];
obsoleteAttributes: Array<{ name: string, tag: string }> = [{name:"replaceable", tag:"template"}];
voids: Array<string> = ['area', 'base', 'br', 'col', 'embed', 'hr',
'img', 'input', 'keygen', 'link', 'meta',
'param', 'source', 'track', 'wbr'];
scopes: Array<string> = ['html', 'body', 'template', 'svg', 'math'];
containers: Array<string> = ['table', 'select'];
customRules: Rule[] = [];
}
import {Config} from './config';

export class AureliaLinter {
linter: Linter;
Expand Down
35 changes: 35 additions & 0 deletions source/config.ts
@@ -0,0 +1,35 @@
import {Rule} from 'template-lint';
import {ConflictingAttributesRule} from './conflictingattributes';


export class Config {
obsoleteTags: Array<{ tag: string, msg: string }> = [
{
tag: 'content',
msg: 'use slot instead'
}
];

obsoleteAttributes: Array<{ name: string, tag: string, msg: string }> = [
{
name: "replaceable",
tag: "template",
msg: "'replaceable' on template has been superceded by the slot element"
}
];

conflictingAttributes: Array<{ tags: string[], msg: string }> = [
{
tags: ["repeat.for", "if.bind", "with.bind"],
msg: "template controllers shouldn't be placed to the same element"
}
];

voids: Array<string> = ['area', 'base', 'br', 'col', 'embed', 'hr',
'img', 'input', 'keygen', 'link', 'meta',
'param', 'source', 'track', 'wbr'];

scopes: Array<string> = ['html', 'body', 'template', 'svg', 'math'];
containers: Array<string> = ['table', 'select'];
customRules: Rule[] = [];
}
5 changes: 2 additions & 3 deletions source/conflictingattributes.ts
Expand Up @@ -12,8 +12,7 @@ export class ConflictingAttributes {
* Rule to ensure tags don't have attributes that shouldn't be used at the same time.
*/
export class ConflictingAttributesRule extends Rule {
static TEMPLATE_CONTROLLER_ATTRIBUTES_ERRMSG_PREFIX = /*"template controllers shouldn't be placed to the same element, */ "conflicting attributes: ";
static TEMPLATE_CONTROLLER_ATTRIBUTES_ERRMSG_DESCRIPTION = "template controllers shouldn't be placed to the same element";
static ERRMSG_PREFIX = "conflicting attributes: ";

constructor(public conflictingAttributesList?: ConflictingAttributes[]) {
super();
Expand All @@ -26,7 +25,7 @@ export class ConflictingAttributesRule extends Rule {

static createDefaultConflictingAttributes() {
return [
new ConflictingAttributes(["repeat.for", "if.bind", "with.bind"], ConflictingAttributesRule.TEMPLATE_CONTROLLER_ATTRIBUTES_ERRMSG_PREFIX),
new ConflictingAttributes(["repeat.for", "if.bind", "with.bind"], ConflictingAttributesRule.ERRMSG_PREFIX),
];
}

Expand Down
4 changes: 2 additions & 2 deletions spec/conflictingattributes.spec.ts
Expand Up @@ -30,7 +30,7 @@ describe("ConflictingAttributes Rule", () => {
linter.lint(DEFAULT_RULES_VIOLATION_SAMPLE)
.then((errors) => {
const errMsg = getLoneError(errors).message;
expect(errMsg).toContain(ConflictingAttributesRule.TEMPLATE_CONTROLLER_ATTRIBUTES_ERRMSG_PREFIX);
expect(errMsg).toContain(ConflictingAttributesRule.ERRMSG_PREFIX);
expect(errMsg).toContain("repeat.for");
expect(errMsg).toContain("if.bind");
done();
Expand All @@ -42,7 +42,7 @@ describe("ConflictingAttributes Rule", () => {
linter.lint('<div repeat.for="user of users" with.bind="user"></div>')
.then((errors) => {
const errMsg = getLoneError(errors).message;
expect(errMsg).toContain(ConflictingAttributesRule.TEMPLATE_CONTROLLER_ATTRIBUTES_ERRMSG_PREFIX);
expect(errMsg).toContain(ConflictingAttributesRule.ERRMSG_PREFIX);
expect(errMsg).toContain("repeat.for");
expect(errMsg).toContain("with.bind");
expect(errMsg).not.toContain("if.bind");
Expand Down

0 comments on commit 164690f

Please sign in to comment.