Skip to content

Commit 1359e24

Browse files
committed
[eslint] enable object-shorthand, space-before-function-paren
1 parent 49ada27 commit 1359e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+209
-199
lines changed

.eslintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@
3131
"no-shadow": 1,
3232
"no-var": 2,
3333
"object-curly-spacing": [2, "always"],
34+
"object-shorthand": ["error", "always", {
35+
"ignoreConstructors": false,
36+
"avoidQuotes": true,
37+
}],
3438
"one-var": [2, "never"],
3539
"prefer-const": 2,
3640
"quotes": [2, "single", {
3741
"allowTemplateLiterals": true,
3842
"avoidEscape": true,
3943
}],
4044
"semi": [2, "always"],
45+
"space-before-function-paren": ["error", {
46+
"anonymous": "always",
47+
"named": "never",
48+
"asyncArrow": "always",
49+
}],
50+
4151
"eslint-plugin/consistent-output": [
4252
"error",
4353
"always",

resolvers/webpack/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ exports.resolve = function (source, file, settings) {
163163
const MAX_CACHE = 10;
164164
const _cache = [];
165165
function getResolveSync(configPath, webpackConfig, cwd) {
166-
const cacheKey = { configPath: configPath, webpackConfig: webpackConfig };
166+
const cacheKey = { configPath, webpackConfig };
167167
let cached = find(_cache, function (entry) { return isEqual(entry.key, cacheKey); });
168168
if (!cached) {
169169
cached = {
@@ -265,7 +265,7 @@ function createWebpack1ResolveSync(webpackRequire, resolveConfig, plugins) {
265265
resolver.apply(
266266
resolveConfig.packageAlias
267267
? new DirectoryDescriptionFileFieldAliasPlugin('package.json', resolveConfig.packageAlias)
268-
: function() {},
268+
: function () {},
269269
new ModuleAliasPlugin(resolveConfig.alias || {}),
270270
makeRootPlugin(ModulesInRootPlugin, 'module', resolveConfig.root),
271271
new ModulesInDirectoriesPlugin(
@@ -302,7 +302,7 @@ function createWebpack1ResolveSync(webpackRequire, resolveConfig, plugins) {
302302

303303
resolver.apply.apply(resolver, resolvePlugins);
304304

305-
return function() {
305+
return function () {
306306
return resolver.resolveSync.apply(resolver, arguments);
307307
};
308308
}
@@ -391,7 +391,7 @@ function findExternal(source, externals, context, resolveSync) {
391391
}
392392

393393
function findConfigPath(configPath, packageDir) {
394-
const extensions = Object.keys(interpret.extensions).sort(function(a, b) {
394+
const extensions = Object.keys(interpret.extensions).sort(function (a, b) {
395395
return a === '.js' ? -1 : b === '.js' ? 1 : a.length - b.length;
396396
});
397397
let extension;

resolvers/webpack/test/config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('config', function () {
101101
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'foo.js'));
102102
});
103103

104-
it('finds the config at option env when config is a function', function() {
104+
it('finds the config at option env when config is a function', function () {
105105
const settings = {
106106
config: require(path.join(__dirname, './files/webpack.function.config.js')),
107107
env: {
@@ -113,7 +113,7 @@ describe('config', function () {
113113
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'bar.js'));
114114
});
115115

116-
it('finds the config at option env when config is an array of functions', function() {
116+
it('finds the config at option env when config is an array of functions', function () {
117117
const settings = {
118118
config: require(path.join(__dirname, './files/webpack.function.config.multiple.js')),
119119
env: {
@@ -125,7 +125,7 @@ describe('config', function () {
125125
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'bar.js'));
126126
});
127127

128-
it('passes argv to config when it is a function', function() {
128+
it('passes argv to config when it is a function', function () {
129129
const settings = {
130130
config: require(path.join(__dirname, './files/webpack.function.config.js')),
131131
argv: {
@@ -137,7 +137,7 @@ describe('config', function () {
137137
.and.equal(path.join(__dirname, 'files', 'some', 'bar', 'bar.js'));
138138
});
139139

140-
it('passes a default empty argv object to config when it is a function', function() {
140+
it('passes a default empty argv object to config when it is a function', function () {
141141
const settings = {
142142
config: require(path.join(__dirname, './files/webpack.function.config.js')),
143143
argv: undefined,
@@ -146,7 +146,7 @@ describe('config', function () {
146146
expect(function () { resolve('baz', file, settings); }).to.not.throw(Error);
147147
});
148148

149-
it('prevents async config using', function() {
149+
it('prevents async config using', function () {
150150
const settings = {
151151
config: require(path.join(__dirname, './files/webpack.config.async.js')),
152152
};

src/rules/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
schema: [],
1111
},
1212

13-
create: function (context) {
13+
create(context) {
1414

1515
function checkDefault(specifierType, node) {
1616

src/rules/dynamic-import-chunkname.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
}],
2525
},
2626

27-
create: function (context) {
27+
create(context) {
2828
const config = context.options[0];
2929
const { importFunctions = [] } = config || {};
3030
const { webpackChunknameFormat = '[0-9a-zA-Z-_/.]+' } = config || {};

src/rules/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
schema: [],
5555
},
5656

57-
create: function (context) {
57+
create(context) {
5858
const namespace = new Map([[rootProgram, new Map()]]);
5959

6060
function addNamed(name, node, parent, isType) {

src/rules/exports-last.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ module.exports = {
1515
schema: [],
1616
},
1717

18-
create: function (context) {
18+
create(context) {
1919
return {
20-
Program: function ({ body }) {
20+
Program({ body }) {
2121
const lastNonExportStatementIndex = body.reduce(function findLastIndex(acc, item, index) {
2222
if (isNonExportStatement(item)) {
2323
return index;

src/rules/extensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ module.exports = {
103103
},
104104
},
105105

106-
create: function (context) {
106+
create(context) {
107107

108108
const props = buildProperties(context);
109109

src/rules/first.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module.exports = {
2121
],
2222
},
2323

24-
create: function (context) {
25-
function isPossibleDirective (node) {
24+
create(context) {
25+
function isPossibleDirective(node) {
2626
return node.type === 'ExpressionStatement' &&
2727
node.expression.type === 'Literal' &&
2828
typeof node.expression.value === 'string';

src/rules/named.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
],
2222
},
2323

24-
create: function (context) {
24+
create(context) {
2525
const options = context.options[0] || {};
2626

2727
function checkSpecifiers(key, type, node) {

0 commit comments

Comments
 (0)