@fullstacksjs/eslint-config 7.0.2 → 7.2.1

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 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
- * ~~eslint-plugin-promise~~ ⚠️ Disabled in v7-beta, because it's not currently supports eslint@8 ([Issue](https://github.com/xjamundx/eslint-plugin-promise/issues/218))
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
- // './rules/promise', PENDING: https://github.com/xjamundx/eslint-plugin-promise/issues/218
30
+ './rules/promise',
38
31
  './rules/node',
39
32
  'prettier',
40
33
  ],
package/bin/index.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ const createOptions = require('./lib/createOptions');
4
+ const createTasks = require('./lib/tasks');
5
+
6
+ createOptions()
7
+ .then(createTasks)
8
+ .then(tasks => tasks.run())
9
+ .catch(() => {});
@@ -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;
@@ -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
- plugins: ['jest', 'jest-formatting'],
3
- env: {
4
- 'jest/globals': true,
5
- },
6
- extends: ['./rules/jest'],
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.2",
3
+ "version": "7.2.1",
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",
@@ -50,29 +54,33 @@
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",
57
+ "eslint-plugin-promise": "6.0.0",
53
58
  "eslint-plugin-react-hooks": "4.3.0",
54
59
  "eslint-plugin-react": "7.27.1",
55
60
  "eslint-plugin-simple-import-sort": "7.0.0",
61
+ "inquirer": "8.2.0",
56
62
  "lodash.has": "4.5.2",
57
- "read-pkg-up": "7.0.1"
63
+ "listr": "0.14.3",
64
+ "read-pkg-up": "7.0.1",
65
+ "yargs": "17.3.1"
58
66
  },
59
67
  "devDependencies": {
60
- "eslint": "8.4.1",
61
68
  "eslint-find-rules": "4.0.0",
69
+ "eslint": "8.5.0",
62
70
  "husky": "7.0.4",
63
71
  "lint-staged": "12.1.2",
64
72
  "np": "7.6.0",
65
73
  "npm-run-all": "4.1.5",
66
74
  "pinst": "2.1.6",
67
75
  "prettier": "2.5.1",
68
- "typescript": "4.5.2"
76
+ "typescript": "4.5.4"
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
@@ -25,5 +25,6 @@ module.exports = {
25
25
  'prefer-template': 'error',
26
26
  'require-yield': 'error',
27
27
  'symbol-description': 'error',
28
+ 'prefer-object-has-own': 'warn',
28
29
  },
29
30
  };
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
  {
@@ -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', 'export'], next: 'export' }],
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',