@fullstacksjs/eslint-config 7.0.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/base.js +2 -9
- package/bin/index.js +9 -0
- package/bin/lib/createOptions.js +25 -0
- package/bin/lib/generateFile.js +15 -0
- package/bin/lib/getUserInput.js +24 -0
- package/bin/lib/parseArgs.js +12 -0
- package/bin/lib/tasks.js +27 -0
- package/jest.js +13 -5
- package/package.json +15 -7
- package/rules/es2015.js +1 -0
- package/rules/jest.js +1 -2
- package/rules/strict.js +5 -1
- package/rules/typescript.js +53 -1
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ If you need more advanced `typescript-eslint` rules, then you can extend from `"
|
|
|
115
115
|
* eslint-plugin-simple-import-sort
|
|
116
116
|
* eslint-plugin-fp
|
|
117
117
|
* eslint-plugin-node
|
|
118
|
-
*
|
|
118
|
+
* eslint-plugin-promise
|
|
119
119
|
|
|
120
120
|
That's all. Feel free to use 💛
|
|
121
121
|
|
package/base.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
plugins: [
|
|
3
|
-
'prettier',
|
|
4
|
-
'import',
|
|
5
|
-
'simple-import-sort',
|
|
6
|
-
// 'promise' PENDING: https://github.com/xjamundx/eslint-plugin-promise/issues/218
|
|
7
|
-
'node',
|
|
8
|
-
'fp',
|
|
9
|
-
],
|
|
2
|
+
plugins: ['prettier', 'import', 'simple-import-sort', 'promise', 'node', 'fp'],
|
|
10
3
|
parserOptions: {
|
|
11
4
|
ecmaVersion: 2020,
|
|
12
5
|
sourceType: 'module',
|
|
@@ -34,7 +27,7 @@ module.exports = {
|
|
|
34
27
|
'./rules/style',
|
|
35
28
|
'./rules/variables',
|
|
36
29
|
'./rules/fp',
|
|
37
|
-
|
|
30
|
+
'./rules/promise',
|
|
38
31
|
'./rules/node',
|
|
39
32
|
'prettier',
|
|
40
33
|
],
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const getUserInput = require('./getUserInput');
|
|
2
|
+
const args = require('./parseArgs');
|
|
3
|
+
|
|
4
|
+
const eslintrcConfig = {
|
|
5
|
+
extends: ['@fullstacksjs'],
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const requiredPackages = ['@fullstacksjs/eslint-config', 'eslint', 'prettier'];
|
|
9
|
+
|
|
10
|
+
async function createOptions() {
|
|
11
|
+
const isTechnologyInArgv = args.t != null;
|
|
12
|
+
const optionsFromArgs = { technology: args.t };
|
|
13
|
+
const userInput = isTechnologyInArgv ? optionsFromArgs : await getUserInput();
|
|
14
|
+
|
|
15
|
+
if (userInput.language === 'ts') {
|
|
16
|
+
requiredPackages.push('typescript');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
eslintrc: eslintrcConfig,
|
|
21
|
+
packages: requiredPackages,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = createOptions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { writeFile } = require('fs/promises');
|
|
2
|
+
|
|
3
|
+
function createFileTask(eslintrc, ctx, task) {
|
|
4
|
+
return writeFile('.eslintrc', JSON.stringify(eslintrc, null, 2))
|
|
5
|
+
.then(() => {
|
|
6
|
+
task.title = `.eslintrc - Successfully Generated.`;
|
|
7
|
+
})
|
|
8
|
+
.catch(() => {
|
|
9
|
+
ctx.isEslintrc = false;
|
|
10
|
+
task.title = `Generating .eslintrc file`;
|
|
11
|
+
throw Error("Couldn't create file");
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = createFileTask;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
|
|
3
|
+
function getUserInput() {
|
|
4
|
+
return inquirer.prompt([
|
|
5
|
+
{
|
|
6
|
+
type: 'list',
|
|
7
|
+
name: 'language',
|
|
8
|
+
message: 'which technology are you using?',
|
|
9
|
+
choices: [
|
|
10
|
+
{
|
|
11
|
+
value: 'ts',
|
|
12
|
+
name: 'ESLint alongside TypeScript',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: 'js',
|
|
16
|
+
name: 'ESLint for JavaScript development',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
default: 'js',
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = getUserInput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const yargs = require('yargs');
|
|
2
|
+
|
|
3
|
+
const args = yargs(process.argv.slice(2))
|
|
4
|
+
.alias('t', 'technology')
|
|
5
|
+
.describe('t', 'Which technology are you using')
|
|
6
|
+
.choices('t', ['ts', 'js'])
|
|
7
|
+
.usage('Usage: $0 [-t ts|js]')
|
|
8
|
+
.example('$0 - ts')
|
|
9
|
+
.help('h')
|
|
10
|
+
.alias('h', 'help').argv;
|
|
11
|
+
|
|
12
|
+
module.exports = args;
|
package/bin/lib/tasks.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const Listr = require('listr');
|
|
2
|
+
const util = require('util');
|
|
3
|
+
const exec = util.promisify(require('child_process').exec);
|
|
4
|
+
const createFileTask = require('./generateFile');
|
|
5
|
+
|
|
6
|
+
function createTasks({ packages, eslintrc }) {
|
|
7
|
+
const installTasks = packages.map(pkg => ({
|
|
8
|
+
title: `Installing ${pkg}`,
|
|
9
|
+
task: (ctx, task) => exec(`npm i -D ${pkg}`).then(() => (task.title = `${pkg} Installed`)),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
return new Listr(
|
|
13
|
+
[
|
|
14
|
+
{
|
|
15
|
+
title: 'Installing dependencies using npm',
|
|
16
|
+
task: () => new Listr(installTasks, { exitOnError: true }),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: 'Generating .eslintrc file',
|
|
20
|
+
task: (ctx, task) => createFileTask(eslintrc, ctx, task),
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
{ exitOnError: false },
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = createTasks;
|
package/jest.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
const exts = '(js|jsx|ts|tsx)';
|
|
2
|
+
const dirs = '(test|tests|__test__|__tests__|spec|specs)';
|
|
3
|
+
|
|
1
4
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
files: [`**/${dirs}/**/*.${exts}`, `**/**/*.(spec|test).${exts}`],
|
|
8
|
+
plugins: ['jest', 'jest-formatting'],
|
|
9
|
+
env: {
|
|
10
|
+
'jest/globals': true,
|
|
11
|
+
},
|
|
12
|
+
extends: ['./rules/jest'],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
7
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstacksjs/eslint-config",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "fullstacks <fullstacksjs@gmail.com>",
|
|
6
6
|
"description": "fullstacks eslint config",
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"registry": "https://registry.npmjs.org"
|
|
13
13
|
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"fullstacksjs-eslint": "./bin/index.js"
|
|
16
|
+
},
|
|
14
17
|
"files": [
|
|
18
|
+
"bin",
|
|
15
19
|
"rules",
|
|
16
20
|
"base.js",
|
|
17
21
|
"index.js",
|
|
@@ -45,34 +49,38 @@
|
|
|
45
49
|
"eslint-plugin-cypress": "2.12.1",
|
|
46
50
|
"eslint-plugin-fp": "2.3.0",
|
|
47
51
|
"eslint-plugin-import": "2.25.3",
|
|
48
|
-
"eslint-plugin-jest-formatting": "3.1.0",
|
|
49
52
|
"eslint-plugin-jest": "25.3.0",
|
|
53
|
+
"eslint-plugin-jest-formatting": "3.1.0",
|
|
50
54
|
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
51
55
|
"eslint-plugin-node": "11.1.0",
|
|
52
56
|
"eslint-plugin-prettier": "4.0.0",
|
|
53
|
-
"eslint-plugin-
|
|
57
|
+
"eslint-plugin-promise": "6.0.0",
|
|
54
58
|
"eslint-plugin-react": "7.27.1",
|
|
59
|
+
"eslint-plugin-react-hooks": "4.3.0",
|
|
55
60
|
"eslint-plugin-simple-import-sort": "7.0.0",
|
|
56
61
|
"lodash.has": "4.5.2",
|
|
57
62
|
"read-pkg-up": "7.0.1"
|
|
58
63
|
},
|
|
59
64
|
"devDependencies": {
|
|
60
|
-
"eslint": "8.
|
|
65
|
+
"eslint": "8.5.0",
|
|
61
66
|
"eslint-find-rules": "4.0.0",
|
|
62
67
|
"husky": "7.0.4",
|
|
68
|
+
"inquirer": "8.2.0",
|
|
63
69
|
"lint-staged": "12.1.2",
|
|
70
|
+
"listr": "0.14.3",
|
|
64
71
|
"np": "7.6.0",
|
|
65
72
|
"npm-run-all": "4.1.5",
|
|
66
73
|
"pinst": "2.1.6",
|
|
67
74
|
"prettier": "2.5.1",
|
|
68
|
-
"typescript": "4.5.
|
|
75
|
+
"typescript": "4.5.4",
|
|
76
|
+
"yargs": "17.3.1"
|
|
69
77
|
},
|
|
70
78
|
"peerDependencies": {
|
|
79
|
+
"cypress": ">=8",
|
|
71
80
|
"eslint": ">=7",
|
|
72
81
|
"prettier": "2",
|
|
73
82
|
"react": ">=16",
|
|
74
|
-
"typescript": "4"
|
|
75
|
-
"cypress": ">=8"
|
|
83
|
+
"typescript": "4"
|
|
76
84
|
},
|
|
77
85
|
"peerDependenciesMeta": {
|
|
78
86
|
"typescript": {
|
package/rules/es2015.js
CHANGED
package/rules/jest.js
CHANGED
|
@@ -47,12 +47,11 @@ module.exports = {
|
|
|
47
47
|
'jest/require-top-level-describe': 'off',
|
|
48
48
|
'jest/unbound-method': 'error',
|
|
49
49
|
'jest/valid-describe-callback': 'error',
|
|
50
|
-
'jest/valid-describe': 'error',
|
|
51
50
|
'jest/valid-expect-in-promise': 'error',
|
|
52
51
|
'jest/valid-expect': 'error',
|
|
53
52
|
'jest/valid-title': 'warn',
|
|
54
53
|
|
|
55
|
-
// jest-
|
|
54
|
+
// jest-formatting
|
|
56
55
|
'jest-formatting/padding-around-after-all-blocks': 'warn',
|
|
57
56
|
'jest-formatting/padding-around-after-each-blocks': 'warn',
|
|
58
57
|
'jest-formatting/padding-around-all': 'warn',
|
package/rules/strict.js
CHANGED
|
@@ -16,6 +16,10 @@ module.exports = {
|
|
|
16
16
|
selector: 'default',
|
|
17
17
|
format: ['camelCase'],
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
selector: 'function',
|
|
21
|
+
format: ['camelCase', 'PascalCase'],
|
|
22
|
+
},
|
|
19
23
|
// variables, CONSTANTS, ReactComponents
|
|
20
24
|
{
|
|
21
25
|
selector: 'variable',
|
|
@@ -23,7 +27,7 @@ module.exports = {
|
|
|
23
27
|
},
|
|
24
28
|
{
|
|
25
29
|
selector: 'parameter',
|
|
26
|
-
format: ['camelCase'],
|
|
30
|
+
format: ['camelCase', 'PascalCase'],
|
|
27
31
|
leadingUnderscore: 'allow',
|
|
28
32
|
},
|
|
29
33
|
{
|
package/rules/typescript.js
CHANGED
|
@@ -29,6 +29,58 @@ module.exports = {
|
|
|
29
29
|
'@typescript-eslint/member-naming': 'off',
|
|
30
30
|
'@typescript-eslint/member-ordering': 'off',
|
|
31
31
|
'@typescript-eslint/method-signature-style': ['warn', 'property'],
|
|
32
|
+
'@typescript-eslint/naming-convention': [
|
|
33
|
+
'warn',
|
|
34
|
+
{
|
|
35
|
+
selector: 'default',
|
|
36
|
+
format: ['camelCase'],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
selector: 'function',
|
|
40
|
+
format: ['camelCase', 'PascalCase'],
|
|
41
|
+
},
|
|
42
|
+
// variables, CONSTANTS, ReactComponents
|
|
43
|
+
{
|
|
44
|
+
selector: 'variable',
|
|
45
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
selector: 'parameter',
|
|
49
|
+
format: ['camelCase', 'PascalCase'],
|
|
50
|
+
leadingUnderscore: 'allow',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
selector: 'memberLike',
|
|
54
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
55
|
+
leadingUnderscore: 'allow',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
selector: 'memberLike',
|
|
59
|
+
modifiers: ['static'],
|
|
60
|
+
format: ['camelCase', 'PascalCase'],
|
|
61
|
+
leadingUnderscore: 'allow',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
selector: 'memberLike',
|
|
65
|
+
modifiers: ['private'],
|
|
66
|
+
format: ['camelCase'],
|
|
67
|
+
leadingUnderscore: 'allow',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
selector: 'typeLike',
|
|
71
|
+
format: ['PascalCase'],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
selector: 'enumMember',
|
|
75
|
+
format: ['PascalCase'],
|
|
76
|
+
},
|
|
77
|
+
// disallow I prefix for interfaces
|
|
78
|
+
{
|
|
79
|
+
selector: 'interface',
|
|
80
|
+
format: ['PascalCase'],
|
|
81
|
+
custom: { regex: '^I[A-Z]', match: false },
|
|
82
|
+
},
|
|
83
|
+
],
|
|
32
84
|
'@typescript-eslint/no-array-constructor': 'error',
|
|
33
85
|
'@typescript-eslint/no-base-to-string': 'off', // false negative
|
|
34
86
|
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
|
|
@@ -79,7 +131,7 @@ module.exports = {
|
|
|
79
131
|
'@typescript-eslint/no-useless-constructor': 'error',
|
|
80
132
|
'@typescript-eslint/no-var-requires': 'error',
|
|
81
133
|
'@typescript-eslint/object-curly-spacing': 'warn',
|
|
82
|
-
'@typescript-eslint/padding-line-between-statements': ['warn', { blankLine: 'always', prev: ['return'
|
|
134
|
+
'@typescript-eslint/padding-line-between-statements': ['warn', { blankLine: 'always', prev: ['return'], next: ['export'] }],
|
|
83
135
|
'@typescript-eslint/prefer-as-const': 'warn',
|
|
84
136
|
'@typescript-eslint/prefer-enum-initializers': 'off',
|
|
85
137
|
'@typescript-eslint/prefer-for-of': 'warn',
|