Skip to content

Commit be5561b

Browse files
committed
feat: Reflect ESLint configuration of serverless package
- Prepare dedicated 'browser' and 'node' entry points - Ensure no environment unrelated rules are applied - Skip options that conflict with Prettier
1 parent c4ebb38 commit be5561b

File tree

3 files changed

+127
-10
lines changed

3 files changed

+127
-10
lines changed

Diff for: browser.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
const { join } = require('path');
4+
5+
module.exports = {
6+
// The only way to ensure that ESLint resolves expected config from any location
7+
extends: join(__dirname, 'index.js'),
8+
env: { browser: true },
9+
rules: {
10+
'no-alert': 'error',
11+
},
12+
};

Diff for: index.js

+108-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,114 @@
1-
"use strict";
1+
'use strict';
22

33
module.exports = {
4-
extends: "eslint:recommended",
4+
extends: 'eslint:recommended',
55
env: { es6: true },
66
parserOptions: { ecmaVersion: 2015 },
7+
plugins: ['import'],
78
rules: {
8-
"no-extra-semi": "off", // Handled by Prettier
9-
"no-mixed-spaces-and-tabs": "off", // Handled by Prettier
10-
"no-unexpected-multiline": "off" // Handled by Prettier
11-
}
9+
'array-callback-return': 'error',
10+
'block-scoped-var': 'error',
11+
camelcase: ['error', { properties: 'never' }],
12+
'comma-dangle': ['error', 'always-multiline'],
13+
'consistent-return': 'error',
14+
15+
curly: ['error', 'multi-line'],
16+
'default-case': ['error', { commentPattern: '^no default$' }],
17+
'dot-notation': ['error', { allowKeywords: true }],
18+
eqeqeq: ['error', 'allow-null'],
19+
'guard-for-in': 'error',
20+
21+
'import/export': 'error',
22+
'import/imports-first': ['error', 'absolute-first'],
23+
'import/newline-after-import': 'error',
24+
'import/no-amd': 'error',
25+
'import/no-duplicates': 'error',
26+
'import/no-extraneous-dependencies': [
27+
'error',
28+
{ devDependencies: ['**/*.test.js', '**/scripts/**', '**/tests/**'] },
29+
],
30+
'import/no-mutable-exports': 'error',
31+
'import/no-named-as-default': 'error',
32+
'import/no-named-as-default-member': 'error',
33+
'import/no-unresolved': ['error', { commonjs: true }],
34+
'import/prefer-default-export': 'error',
35+
36+
'max-len': ['error', 100, 2, { ignoreUrls: true }],
37+
'new-cap': ['error', { newIsCap: true }],
38+
'no-array-constructor': 'error',
39+
'no-caller': 'error',
40+
'no-confusing-arrow': ['error', { allowParens: true }],
41+
'no-console': 'error',
42+
'no-duplicate-imports': 'error',
43+
'no-else-return': 'error',
44+
'no-empty-function': ['error', { allow: ['arrowFunctions', 'functions', 'methods'] }],
45+
'no-eval': 'error',
46+
'no-extra-bind': 'error',
47+
'no-extra-label': 'error',
48+
'no-extra-semi': 'off', // Handled by Prettier
49+
'no-implied-eval': 'error',
50+
'no-iterator': 'error',
51+
'no-label-var': 'error',
52+
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
53+
'no-lone-blocks': 'error',
54+
'no-lonely-if': 'error',
55+
'no-loop-func': 'error',
56+
'no-mixed-spaces-and-tabs': 'off', // Handled by Prettier
57+
'no-multi-str': 'error',
58+
'no-nested-ternary': 'error',
59+
'no-new': 'error',
60+
'no-new-func': 'error',
61+
'no-new-object': 'error',
62+
'no-new-require': 'error',
63+
'no-new-wrappers': 'error',
64+
'no-octal-escape': 'error',
65+
'no-param-reassign': ['error', { props: true }],
66+
'no-proto': 'error',
67+
'no-restricted-syntax': [
68+
'error',
69+
'DebuggerStatement',
70+
'ForInStatement',
71+
'LabeledStatement',
72+
'WithStatement',
73+
],
74+
'no-return-assign': 'error',
75+
'no-script-url': 'error',
76+
'no-self-compare': 'error',
77+
'no-sequences': 'error',
78+
'no-shadow': 'error',
79+
'no-throw-literal': 'error',
80+
'no-undef-init': 'error',
81+
'no-underscore-dangle': ['error', { allowAfterThis: false }],
82+
'no-unexpected-multiline': 'off', // Handled by Prettier
83+
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
84+
'no-unused-expressions': ['error', { allowShortCircuit: false, allowTernary: false }],
85+
'no-unused-vars': ['error', { vars: 'local', args: 'after-used' }],
86+
'no-useless-computed-key': 'error',
87+
'no-useless-concat': 'error',
88+
'no-useless-constructor': 'error',
89+
'no-useless-rename': [
90+
'error',
91+
{ ignoreDestructuring: false, ignoreImport: false, ignoreExport: false },
92+
],
93+
'no-var': 'error',
94+
'no-void': 'error',
95+
'object-shorthand': ['error', 'always', { ignoreConstructors: false, avoidQuotes: true }],
96+
'one-var': ['error', 'never'],
97+
'operator-assignment': ['error', 'always'],
98+
quotes: ['error', 'single', { avoidEscape: true }],
99+
'prefer-arrow-callback': ['error', { allowNamedFunctions: false, allowUnboundThis: true }],
100+
'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: true }],
101+
'prefer-rest-params': 'error',
102+
'prefer-spread': 'error',
103+
'prefer-template': 'error',
104+
radix: 'error',
105+
'vars-on-top': 'error',
106+
'spaced-comment': ['error', 'always', { exceptions: ['-', '+'], markers: ['=', '!'] }],
107+
strict: ['error', 'safe'],
108+
yoda: 'error',
109+
},
110+
overrides: [
111+
{ files: ['**/*.test.js', '**/tests/**'], env: { mocha: true, jest: true } },
112+
{ files: ['jest.setupEnvironment.js'], env: { jest: true } },
113+
],
12114
};

Diff for: node.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
"use strict";
1+
'use strict';
22

3-
const { join } = require("path");
3+
const { join } = require('path');
44

55
module.exports = {
66
// The only way to ensure that ESLint resolves expected config from any location
7-
extends: join(__dirname, "index.js"),
8-
env: { node: true }
7+
extends: join(__dirname, 'index.js'),
8+
env: { node: true },
9+
rules: {
10+
'no-path-concat': 'error',
11+
},
912
};

0 commit comments

Comments
 (0)