Skip to content

Commit

Permalink
lint 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
zlq4863947 committed Jan 23, 2019
1 parent 29807c2 commit f29ed19
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 11 deletions.
68 changes: 68 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -134,6 +134,7 @@
"protractor": "5.1.2",
"rimraf": "2.6.1",
"rxjs-tslint": "^0.1.6",
"rxjs-tslint-rules": "^4.15.0",
"stylelint": "7.13.0",
"ts-node": "^8.0.1",
"tslint": "5.7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/@theme/components/footer/footer.component.ts
Expand Up @@ -5,7 +5,7 @@ import { Component } from '@angular/core';
styleUrls: ['./footer.component.scss'],
template: `
<span class="created-by"
>Created with ♥ by <b><a href="https://github.com/zlq4863947" target="_blank">zlq4863947</a></b> 2018</span
>Created with ♥ by <b><a href="https://github.com/zlq4863947" target="_blank">zlq4863947</a></b> 2018</span
>
<div class="socials">
<a href="#" class="ion ion-social-github"></a>
Expand Down
Expand Up @@ -22,7 +22,7 @@ export class LayoutDirectionSwitcherComponent implements OnDestroy {
currentDirection: NbLayoutDirection;
alive = true;

@Input() vertical: boolean = false;
@Input() vertical = false;

constructor(private directionService: NbLayoutDirectionService) {
this.currentDirection = this.directionService.getDirection();
Expand Down
Expand Up @@ -12,7 +12,7 @@ import { ThemeSwitcherListComponent } from './themes-switcher-list/themes-switch
export class ThemeSwitcherComponent {
@ViewChild(NbPopoverDirective) popover: NbPopoverDirective;

@Input() showTitle: boolean = true;
@Input() showTitle = true;

switcherListComponent = ThemeSwitcherListComponent;
theme: NbJSThemeOptions;
Expand Down
4 changes: 2 additions & 2 deletions src/app/@theme/layouts/one-column/one-column.layout.ts
Expand Up @@ -30,10 +30,10 @@ import { takeWhile } from 'rxjs/operators';
`,
})
export class OneColumnLayoutComponent implements OnDestroy {
private alive = true;

currentTheme: string;

private alive = true;

constructor(protected themeService: NbThemeService) {
this.themeService
.getJsTheme()
Expand Down
4 changes: 2 additions & 2 deletions src/app/@theme/layouts/sample/sample.layout.ts
Expand Up @@ -89,10 +89,10 @@ export class SampleLayoutComponent implements OnDestroy {
layout: any = {};
sidebar: any = {};

private alive = true;

currentTheme: string;

private alive = true;

constructor(
protected stateService: StateService,
protected menuService: NbMenuService,
Expand Down
4 changes: 2 additions & 2 deletions src/app/@theme/layouts/three-columns/three-columns.layout.ts
Expand Up @@ -34,10 +34,10 @@ import { takeWhile } from 'rxjs/operators';
`,
})
export class ThreeColumnsLayoutComponent implements OnDestroy {
private alive = true;

currentTheme: string;

private alive = true;

constructor(protected themeService: NbThemeService) {
this.themeService
.getJsTheme()
Expand Down
4 changes: 2 additions & 2 deletions src/app/@theme/layouts/two-columns/two-columns.layout.ts
Expand Up @@ -32,10 +32,10 @@ import { takeWhile } from 'rxjs/operators';
`,
})
export class TwoColumnsLayoutComponent implements OnDestroy {
private alive = true;

currentTheme: string;

private alive = true;

constructor(protected themeService: NbThemeService) {
this.themeService
.getJsTheme()
Expand Down
35 changes: 35 additions & 0 deletions tools/stylelint/no-nested-mixin/index.js
@@ -0,0 +1,35 @@
const stylelint = require('stylelint');

const ruleName = 'bitbank/no-nested-mixin';
const messages = stylelint.utils.ruleMessages(ruleName, {
expected: () => 'Nested mixins are not allowed.',
});


/**
* Stylelint plugin that prevents nesting SASS mixins.
*/
const plugin = stylelint.createPlugin(ruleName, isEnabled => {
return (root, result) => {
if (!isEnabled) return;

root.walkAtRules(rule => {
if (rule.name !== 'mixin') return;

rule.walkAtRules(childRule => {
if (childRule.name !== 'mixin') return;

stylelint.utils.report({
result,
ruleName,
message: messages.expected(),
node: childRule
});
});
});
};
});

plugin.ruleName = ruleName;
plugin.messages = messages;
module.exports = plugin;
46 changes: 46 additions & 0 deletions tools/stylelint/selector-nested-pattern-scoped/index.js
@@ -0,0 +1,46 @@
const stylelint = require('stylelint');
const path = require('path');
const isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule');
const isStandardSyntaxSelector = require('stylelint/lib/utils/isStandardSyntaxSelector');

const ruleName = 'bitbank/selector-nested-pattern-scoped';
const messages = stylelint.utils.ruleMessages(ruleName, {
expected: selector => `Expected nested selector '${selector}' to match specified pattern`,
});

/**
* Re-implementation of the `selector-nested-pattern` Stylelint rule, allowing us
* to scope it to a particular set of files via the custom `filePattern` option. The
* primary use-case is to be able to apply the rule only to theme files.
*
* Reference: https://stylelint.io/user-guide/rules/selector-nested-pattern/
* Source: https://github.com/stylelint/stylelint/blob/master/lib/rules/selector-nested-pattern/
*/
const plugin = stylelint.createPlugin(ruleName, (pattern, options) => {
return (root, result) => {
const selectorPattern = new RegExp(pattern);
const filePattern = new RegExp(options.filePattern);
const fileName = path.basename(root.source.input.file);

if (!filePattern.test(fileName)) return;

root.walkRules(rule => {
if (rule.parent.type === 'rule' &&
isStandardSyntaxRule(rule) &&
isStandardSyntaxSelector(rule.selector) &&
!selectorPattern.test(rule.selector)) {

stylelint.utils.report({
result,
ruleName,
message: messages.expected(rule.selector),
node: rule
});
}
});
};
});

plugin.ruleName = ruleName;
plugin.messages = messages;
module.exports = plugin;
37 changes: 37 additions & 0 deletions tools/stylelint/selector-no-deep/index.js
@@ -0,0 +1,37 @@
const stylelint = require('stylelint');
const isStandardSyntaxRule = require('stylelint/lib/utils/isStandardSyntaxRule');
const isStandardSyntaxSelector = require('stylelint/lib/utils/isStandardSyntaxSelector');

const ruleName = 'bitbank/selector-no-deep';
const messages = stylelint.utils.ruleMessages(ruleName, {
expected: selector => `Usage of the /deep/ in "${selector}" is not allowed`,
});


/**
* Stylelint plugin that prevents uses of /deep/ in selectors.
*/
const plugin = stylelint.createPlugin(ruleName, isEnabled => {
return (root, result) => {
if (!isEnabled) return;

root.walkRules(rule => {
if (rule.parent.type === 'rule' &&
isStandardSyntaxRule(rule) &&
isStandardSyntaxSelector(rule.selector) &&
rule.selector.includes('/deep/')) {

stylelint.utils.report({
result,
ruleName,
message: messages.expected(rule.selector),
node: rule
});
}
});
};
});

plugin.ruleName = ruleName;
plugin.messages = messages;
module.exports = plugin;

0 comments on commit f29ed19

Please sign in to comment.