Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ESLint config #227

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 18 additions & 48 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
{
"parserOptions": {
"sourceType": "script",
"impliedStrict": false
},
"env": {
"browser": false,
"es6": true,
"node": true
},
"extends": [
"standard"
],
"parserOptions": {
"sourceType": "script",
"ecmaVersion": 2017
},
"root": true,
"rules": {
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"comma-dangle": [
"error",
{
Expand All @@ -37,37 +29,22 @@
"before": false
}
],
"eol-last": [
"error",
"always"
],
"eqeqeq": [
"error",
"smart"
],
"indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"no-console": [
"error"
],
"no-tabs": [
"off"
],
"no-var": [
"error"
],
"prefer-arrow-callback": [
"error"
],
"prefer-const": [
"error"
],
Expand All @@ -86,26 +63,19 @@
"omitLastInOneLineBlock": false
}
],
"space-before-blocks": [
"error",
"always"
],
"space-infix-ops": [
"error"
],
"spaced-comment": [
"error",
"always"
],
"strict": [
"error",
"safe"
],
"valid-jsdoc": [
"error",
{
"requireReturn": false
}
]
}
},
"overrides": [
{
"files": [
"test/**/*"
],
"env": {
"mocha": true
}
}
]
}
2 changes: 1 addition & 1 deletion lib/ci-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function checkstyle (errors) {

function getErrorsByFile (errors) {
const result = {};
errors.forEach(function (error) {
errors.forEach((error) => {
if (result[error.fileName]) {
result[error.fileName].push(error);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/eslint-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function docUrl (rule, error) {
return `https://${locale === 'zh_CN' ? 'cn.' : ''}eslint.org/docs/rules/${rule}`;
}
if (baseUrl) {
if (typeof baseUrl == 'function') {
if (typeof baseUrl === 'function') {
try {
return baseUrl(rule, error);
} catch (ex) {
Expand Down
2 changes: 1 addition & 1 deletion lib/get-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function getErrors (file, options) {

}) : Promise.resolve()).then(blames => {
// blame信息写入error对象
errors.forEach(function (error) {
errors.forEach((error) => {
if (!error.fileName) {
error.fileName = file.path;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/get-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function (options) {
expires = new Date(expires);
}
}
if (typeof expires == 'number') {
if (typeof expires === 'number') {
if (expires <= 0 || isNaN(expires)) {
throw new TypeError('`options.expires` must be greater than 0.');
}
Expand Down
8 changes: 4 additions & 4 deletions lib/js-browser-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function jsBrowserReporter (errors) {
var isGecko = !!window.netscape;

var throwError = isGecko ? function (message, stack, err) {
stack = stack.map(function (uri) {
stack = stack.map((uri) => {
return '@' + uri;
});
if (!err.severity || err.severity === 'error') {
Expand All @@ -22,14 +22,14 @@ function jsBrowserReporter (errors) {
error.fileName = err.fileName;
error.lineNumber = err.lineNumber;
error.stack = stack.join('\n');
setTimeout(function () {
setTimeout(() => {
throw error;
}, 0);
} else {
consoleError(message, stack, err);
}
} : function (message, stack, err) {
stack = stack.map(function (uri) {
stack = stack.map((uri) => {
return ' at ' + uri;
});
consoleError(message, stack, err);
Expand All @@ -43,7 +43,7 @@ function jsBrowserReporter (errors) {
}

// 将文件路径与模块路径拼接为完整的url
errors.forEach(function (err) {
errors.forEach((err) => {
var message = err.message + ' (' + [
err.plugin,
err.rule,
Expand Down
2 changes: 1 addition & 1 deletion lib/lint-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class LintError extends Error {
if (this.doc) {
stack.push(this.doc);
}
stack = stack.map(function (uri) {
stack = stack.map((uri) => {
return ' at ' + uri;
});
stack.unshift(message);
Expand Down
2 changes: 1 addition & 1 deletion lib/stylint-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class StyLintError extends LintError {
// 报错插件
plugin: 'StyLint',
};
message.replace(/^(.+?):\s*(.+?)$/gm, function (s, key, value) {
message.replace(/^(.+?):\s*(.+?)$/gm, (s, key, value) => {
if (/^(?:error|warn(?:ing)?|info)$/i.test(key)) {
key = key.toLowerCase();
error.severity = STYLLINT_SEVERITY_MAP[key] || key;
Expand Down
14 changes: 0 additions & 14 deletions test/.eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ describe('API', () => {
' 01:01 \u{2714} testcase message.',
]);
if (padStart) {
/* eslint no-extend-native: "off"*/
/* eslint no-extend-native: "off" */
String.prototype.padStart = padStart;
}
if (VSCODE_PID) {
Expand Down
2 changes: 1 addition & 1 deletion test/ci.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path');
const os = require('os');
const env = process.env;

describe('CI', function () {
describe('CI', () => {
const mkdtemp = fs.mkdtemp.bind(fs, path.join(os.tmpdir(), 'gulp-reporter-ci-'));
let tempDir;

Expand Down
2 changes: 1 addition & 1 deletion test/postcss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const postcss = require('gulp-html-postcss');
const stylelint = require('stylelint');
const sandbox = require('./sandbox');

describe('PostCSS', function () {
describe('PostCSS', () => {
it('PostCSSError', () => {
const PostCSSError = proxyquire('../lib/postcss-error', {
'./lint-error': proxyquire('../lib/lint-error', {
Expand Down
2 changes: 1 addition & 1 deletion test/stylint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const reporter = require('../');
const sandbox = require('./sandbox');
const StyLintError = require('../lib/stylint-error');

describe('stylint', function () {
describe('stylint', () => {
it('StyLintError', () => {
const error = new StyLintError('mock: value');
assert.equal(error.mock, 'value');
Expand Down