eslint-config-simplesense 3.1.12 → 4.0.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 CHANGED
@@ -1,4 +1,4 @@
1
- # SimpleSense ESLint Config
1
+ # Simplesense ESLint Config
2
2
 
3
3
  [![GitHub Pages](https://img.shields.io/static/v1?label=GitHub&message=Pages&color=informational&style=flat-square&logo=github)](https://simplesenseio.github.io/eslint-config-simplesense/)
4
4
  [![Build](https://github.com/simplesenseio/eslint-config-simplesense/actions/workflows/build.yaml/badge.svg?branch=main&style=flat-square)](https://github.com/simplesenseio/eslint-config-simplesense/actions/workflows/build.yaml)
@@ -21,8 +21,8 @@ Adding plugins is fairly straightforward.
21
21
 
22
22
  **Step 1**
23
23
 
24
- - To simply use a recommended configuration, add the plugin as a dependency and add the recommendation to the `extends` array in [`index.js`](./index.js).
25
- - To configure custom rules for a plugin, add a new file, [`plugins/<plugin-name>.js`](./plugins/), and export the rules object. Then add a `require` statement to [`index.js`](./index.js) in the `plugins` object. You can also add a recommended config to the `extends` array.
24
+ - To simply use a recommended configuration, add the plugin as a dependency and add config to the [config](./config/) directory that imports the recommended rules and the plugin itself. Then add the config to the exported array in [`index.js`](./index.js).
25
+ - To configure custom rules for a plugin, add a new file, [`rules/<plugin-name>.js`](./rules/), and export the rules object. Then add the config by following the details in the previous step, however, use the custom rules by themselves or with the exported recommended rules of the plugin.
26
26
  - If the new plugin lints a new file type, add a `index.<filetype>` file to the [`filetypes`](./filetypes/) directory and update the `lint:eslint` script in [`package.json`](./package.json) to include the new extension.
27
27
 
28
28
  **Step 2**
@@ -0,0 +1,11 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ name: 'simplesense/array-func',
6
+ plugins: {
7
+ 'array-func': require('eslint-plugin-array-func'),
8
+ },
9
+ rules: require('../rules/array-func'),
10
+ };
11
+ })();
@@ -0,0 +1,13 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const plugin = require('@eslint-community/eslint-plugin-eslint-comments');
5
+
6
+ module.exports = {
7
+ name: 'simplesense/eslint-comments',
8
+ plugins: {
9
+ '@eslint-community/eslint-comments': plugin,
10
+ },
11
+ rules: plugin.configs.recommended.rules,
12
+ };
13
+ })();
@@ -0,0 +1,15 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const {
5
+ configs,
6
+ } = require('@eslint/js');
7
+
8
+ module.exports = {
9
+ name: 'simplesense/eslint',
10
+ rules: {
11
+ ...configs.recommended.rules,
12
+ ...require('../rules/eslint-recommended'),
13
+ },
14
+ };
15
+ })();
@@ -0,0 +1,11 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ name: 'simplesense/import',
6
+ plugins: {
7
+ import: require('eslint-plugin-import'),
8
+ },
9
+ rules: require('../rules/import'),
10
+ };
11
+ })();
@@ -0,0 +1,13 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const plugin = require('eslint-plugin-no-use-extend-native');
5
+
6
+ module.exports = {
7
+ name: 'simplesense/no-use-extend-native',
8
+ plugins: {
9
+ 'no-use-extend-native': plugin,
10
+ },
11
+ rules: plugin.configs.recommended.rules,
12
+ };
13
+ })();
package/config/node.js ADDED
@@ -0,0 +1,11 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ name: 'simplesense/node',
6
+ plugins: {
7
+ n: require('eslint-plugin-n'),
8
+ },
9
+ rules: require('../rules/node'),
10
+ };
11
+ })();
@@ -0,0 +1,13 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const plugin = require('eslint-plugin-optimize-regex');
5
+
6
+ module.exports = {
7
+ name: 'simplesense/optimize-regex',
8
+ plugins: {
9
+ 'optimize-regex': plugin,
10
+ },
11
+ rules: plugin.configs.recommended.rules,
12
+ };
13
+ })();
@@ -0,0 +1,13 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const {
5
+ configs,
6
+ } = require('eslint-plugin-regexp');
7
+
8
+ const config = {
9
+ ...configs['flat/recommended'],
10
+ };
11
+
12
+ module.exports = config;
13
+ })();
@@ -0,0 +1,11 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ name: 'simplesense/security',
6
+ plugins: {
7
+ security: require('eslint-plugin-security'),
8
+ },
9
+ rules: require('../rules/security'),
10
+ };
11
+ })();
@@ -0,0 +1,16 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const plugin = require('eslint-plugin-sonarjs');
5
+
6
+ module.exports = {
7
+ name: 'simplesense/sonarjs',
8
+ plugins: {
9
+ sonarjs: plugin,
10
+ },
11
+ rules: {
12
+ ...plugin.configs.recommended.rules,
13
+ ...require('../rules/sonarjs'),
14
+ },
15
+ };
16
+ })();
@@ -0,0 +1,11 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ name: 'simplesense/unicorn',
6
+ plugins: {
7
+ unicorn: require('eslint-plugin-unicorn'),
8
+ },
9
+ rules: require('../rules/unicorn'),
10
+ };
11
+ })();
package/config/vue.js ADDED
@@ -0,0 +1,17 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const plugin = require('eslint-plugin-vue');
5
+
6
+ module.exports = [
7
+ ...plugin.configs['flat/vue2-strongly-recommended'],
8
+ {
9
+ name: 'simplesense/vue',
10
+ files: [ '*.vue', '**/*.vue' ],
11
+ plugins: {
12
+ vue: plugin,
13
+ },
14
+ rules: require('../rules/vue'),
15
+ },
16
+ ];
17
+ })();
package/config/yaml.js ADDED
@@ -0,0 +1,17 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const plugin = require('eslint-plugin-yml');
5
+
6
+ module.exports = [
7
+ ...plugin.configs['flat/standard'],
8
+ {
9
+ name: 'simplesense/yaml',
10
+ files: [ '*.yaml', '**/*.yaml', '*.yml', '**/*.yml' ],
11
+ plugins: {
12
+ yaml: plugin,
13
+ },
14
+ rules: require('../rules/yaml'),
15
+ },
16
+ ];
17
+ })();
package/index.js CHANGED
@@ -1,111 +1,56 @@
1
1
  (() => {
2
2
  'use strict';
3
3
 
4
- const EXTENDS = {
5
- 'eslint:recommended': require('./plugins/eslint-recommended'),
6
- };
4
+ const globals = require('globals');
7
5
 
8
- const PLUGINS = {
9
- 'array-func': require('./plugins/array-func'),
10
- import: require('./plugins/import'),
11
- node: require('./plugins/node'),
12
- security: require('./plugins/security'),
13
- sonarjs: require('./plugins/sonarjs'),
14
- unicorn: require('./plugins/unicorn'),
15
- };
6
+ // remove this and the core-js dependency
7
+ // when we drop support for node 16
8
+ if (!('structuredClone' in globalThis)) {
9
+ // eslint-disable-next-line import/no-unassigned-import
10
+ require('core-js/actual');
11
+ }
16
12
 
17
- module.exports = {
18
- extends: [
19
- ...Object.keys(EXTENDS),
20
- 'plugin:eslint-comments/recommended',
21
- 'plugin:no-use-extend-native/recommended',
22
- 'plugin:optimize-regex/recommended',
23
- 'plugin:regexp/recommended',
24
- 'plugin:sonarjs/recommended',
25
- ],
26
- plugins: [
27
- ...Object.keys(PLUGINS),
28
- 'optimize-regex',
29
- 'eslint-comments',
30
- 'no-use-extend-native',
31
- 'regexp',
32
- ],
33
- env: {
34
- browser: true,
35
- es2021: true,
36
- es6: true,
37
- jest: true,
38
- node: true,
39
- },
40
- parserOptions: {
41
- ecmaVersion: 2021,
42
- },
43
- ignorePatterns: [
44
- '!.*',
45
- '.cache/',
46
- '.git/',
47
- '.github/actions/',
48
- '.npm/',
49
- '.nyc_output/',
50
- 'coverage/',
51
- 'lib-cov/',
52
- 'node_modules/',
53
- '**/*.min.*',
54
- ],
55
- rules: [
56
- ...Object.values(EXTENDS),
57
- ...Object.values(PLUGINS),
58
- ].reduce((object, value) => Object.assign(object, value), {}),
59
- overrides: [
60
- {
61
- files: ['*.vue'],
62
- extends: [
63
- 'plugin:vue/recommended',
64
- 'plugin:vue/strongly-recommended',
65
- 'plugin:vue/essential',
66
- ],
67
- plugins: ['vue'],
68
- rules: {
69
- 'unicorn/filename-case': [
70
- 'error', {
71
- case: 'pascalCase',
72
- },
73
- ],
74
- 'vue/component-name-in-template-casing': [ 'error', 'kebab-case' ],
75
- 'vue/component-definition-name-casing': [ 'error', 'kebab-case' ],
76
- 'vue/singleline-html-element-content-newline': 'off',
77
- },
78
- }, {
79
- files: [ '*.yml', '*.yaml' ],
80
- extends: ['plugin:yml/standard'],
81
- plugins: ['yml'],
82
- rules: {
83
- 'yml/block-sequence': [ 'error', 'always' ],
84
- 'yml/file-extension': [
85
- 'error',
86
- {
87
- extension: 'yaml',
88
- caseSensitive: true,
89
- },
90
- ],
91
- 'yml/indent': [
92
- 'error',
93
- 2,
94
- {
95
- indentBlockSequences: true,
96
- },
97
- ],
98
- 'yml/no-empty-document': ['off'],
99
- 'yml/quotes': [
100
- 'error', {
101
- prefer: 'single',
102
- },
103
- ],
13
+ module.exports = [
14
+ require('./config/eslint'),
15
+ require('./config/array-func'),
16
+ require('./config/eslint-comments'),
17
+ require('./config/import'),
18
+ require('./config/no-use-extend-native'),
19
+ require('./config/node'),
20
+ require('./config/optimize-regex'),
21
+ require('./config/regexp'),
22
+ require('./config/security'),
23
+ require('./config/sonarjs'),
24
+ require('./config/unicorn'),
25
+ ...require('./config/vue'), // exports an array
26
+ ...require('./config/yaml'), // exports an array
27
+ {
28
+ languageOptions: {
29
+ sourceType: 'commonjs',
30
+ globals: {
31
+ ...globals.browser,
32
+ ...globals.es2021,
33
+ ...globals.es6,
34
+ ...globals.jest,
35
+ ...globals.node,
36
+ spyFn: true,
104
37
  },
105
38
  },
106
- ],
107
- globals: {
108
- spyFn: true,
109
39
  },
110
- };
40
+ {
41
+ // it's a bit confusing, but this needs to be in a config all by itself
42
+ // https://github.com/eslint/eslint/issues/17400
43
+ ignores: [
44
+ '!.*',
45
+ '.cache/',
46
+ '.git/',
47
+ '.github/actions/',
48
+ '.npm/',
49
+ 'coverage/',
50
+ 'lib-cov/',
51
+ 'node_modules/',
52
+ '**/*.min.*',
53
+ ],
54
+ },
55
+ ];
111
56
  })();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-config-simplesense",
3
- "version": "3.1.12",
4
- "description": "ESLint Config for SimpleSense Styles",
3
+ "version": "4.0.0",
4
+ "description": "ESLint Config for Simplesense Styles",
5
5
  "keywords": [
6
6
  "eslint",
7
7
  "config",
@@ -20,26 +20,31 @@
20
20
  "main": "index.js",
21
21
  "files": [
22
22
  "index.js",
23
- "plugins/**/*"
23
+ "config/**/*",
24
+ "rules/**/*"
24
25
  ],
25
26
  "scripts": {
26
- "docs": "npm run docs:clean && npm run docs:generate && npm run docs:build && npm run docs:mv && npm run docs:nojekyll",
27
- "docs:build": "vuepress build docs",
28
- "docs:clean": "rm -rf docs/.vuepress/dist ./dist",
29
- "docs:dev": "npm run docs:clean && npm run docs:generate && vuepress dev docs",
27
+ "configs:build": "node scripts/generate-configs.js",
28
+ "docs": "npm run docs:clean && npm run docs:generate && npm run vitepress:sidebar && npm run docs:build && npm run docs:mv && npm run docs:nojekyll",
29
+ "docs:build": "vitepress build docs",
30
+ "docs:clean": "rm -rf docs/.vitepress/dist ./dist",
31
+ "docs:dev": "npm run docs:clean && npm run docs:generate && npm run vitepress:sidebar && vitepress dev docs",
30
32
  "docs:generate": "node scripts/generate-docs.js",
31
- "docs:mv": "mv docs/.vuepress/dist ./",
33
+ "docs:mv": "mv docs/.vitepress/dist ./",
32
34
  "docs:nojekyll": "touch dist/.nojekyll",
33
35
  "lint": "npm run lint:package-json && npm run lint:eslint",
34
- "lint:eslint": "eslint --config index.js --fix '**/*.{js,vue,yaml,yml}'",
36
+ "lint:eslint": "eslint --fix '**/*.{mjs,js,vue,yaml,yml}'",
35
37
  "lint:package-json": "sort-package-json",
36
- "test": "jest"
38
+ "pretest": "npm run configs:build",
39
+ "test": "NODE_OPTIONS=\"${NODE_OPTIONS} --experimental-vm-modules\" jest",
40
+ "vitepress:sidebar": "node scripts/generate-vitepress-sidebar.js"
37
41
  },
38
42
  "jest": {
39
43
  "collectCoverage": true,
40
44
  "collectCoverageFrom": [
41
45
  "index.js",
42
- "plugins/*.js"
46
+ "config/*.js",
47
+ "rules/*.js"
43
48
  ],
44
49
  "moduleNameMapper": {
45
50
  "eslint/use-at-your-own-risk": "eslint/lib/unsupported-api"
@@ -58,29 +63,29 @@
58
63
  "verbose": true
59
64
  },
60
65
  "dependencies": {
66
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
67
+ "@eslint/js": "^9.0.0",
68
+ "core-js": "^3.36.1",
61
69
  "eslint-plugin-array-func": "^4.0.0",
62
- "eslint-plugin-eslint-comments": "^3.2.0",
63
70
  "eslint-plugin-import": "^2.29.1",
71
+ "eslint-plugin-n": "^17.2.1",
64
72
  "eslint-plugin-no-use-extend-native": "^0.5.0",
65
- "eslint-plugin-node": "^11.1.0",
66
73
  "eslint-plugin-optimize-regex": "^1.2.1",
67
- "eslint-plugin-regexp": "^2.2.0",
68
- "eslint-plugin-security": "^2.1.1",
69
- "eslint-plugin-sonarjs": "^0.24.0",
70
- "eslint-plugin-unicorn": "^51.0.1",
71
- "eslint-plugin-vue": "^9.22.0",
72
- "eslint-plugin-yml": "^1.12.2"
74
+ "eslint-plugin-regexp": "^2.5.0",
75
+ "eslint-plugin-security": "^3.0.0",
76
+ "eslint-plugin-sonarjs": "^0.25.1",
77
+ "eslint-plugin-unicorn": "^52.0.0",
78
+ "eslint-plugin-vue": "^9.25.0",
79
+ "eslint-plugin-yml": "^1.14.0",
80
+ "globals": "^15.0.0"
73
81
  },
74
82
  "devDependencies": {
75
- "@vuepress/plugin-pwa": "^1.9.10",
76
83
  "eslint": "^8.57.0",
77
- "hash-sum": "^2.0.0",
78
84
  "jest": "^29.7.0",
79
- "sort-package-json": "^2.8.0",
80
- "vuepress": "^1.9.10",
81
- "vuepress-theme-default-prefers-color-scheme": "^2.0.0"
85
+ "sort-package-json": "^2.10.0",
86
+ "vitepress": "^1.1.0"
82
87
  },
83
88
  "peerDependencies": {
84
- "eslint": ">=8.0.0"
89
+ "eslint": "8.x"
85
90
  }
86
91
  }
package/rules/node.js ADDED
@@ -0,0 +1,71 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ const path = require('path');
5
+
6
+ const NODE_VERSION = '>=14.0.0';
7
+ const ROOT_DIR = path.resolve(__dirname, '../../../'); // this will be in <PROJECT>/node_modules/eslint-config-simplesense/rules/
8
+
9
+ module.exports = {
10
+ 'n/callback-return': [
11
+ 'error', [
12
+ 'callback',
13
+ 'cb',
14
+ 'done',
15
+ 'next',
16
+ ],
17
+ ],
18
+ // not used because it does not support IIFE
19
+ // 'n/global-require': ['error'],
20
+ 'n/handle-callback-err': ['error'],
21
+ 'n/no-deprecated-api': [
22
+ 'error', {
23
+ version: NODE_VERSION,
24
+ },
25
+ ],
26
+ 'n/no-missing-import': ['error'],
27
+ 'n/no-missing-require': [
28
+ 'error', {
29
+ allowModules: ['aws-sdk'],
30
+ resolvePaths: [path.resolve(__dirname, `${ ROOT_DIR }/lambda/layers/node-modules/nodejs/node_modules`)],
31
+ },
32
+ ],
33
+ 'n/no-mixed-requires': [
34
+ 'error', {
35
+ allowCall: true,
36
+ grouping: true,
37
+ },
38
+ ],
39
+ 'n/no-new-require': ['error'],
40
+ 'n/no-path-concat': ['error'],
41
+ 'n/no-unsupported-features/es-builtins': [
42
+ 'error', {
43
+ version: NODE_VERSION,
44
+ },
45
+ ],
46
+ 'n/no-unsupported-features/es-syntax': ['off'],
47
+ 'n/no-unsupported-features/node-builtins': [
48
+ 'error', {
49
+ version: NODE_VERSION,
50
+ },
51
+ ],
52
+ 'n/no-unpublished-bin': ['error'],
53
+ 'n/no-unpublished-import': ['error'],
54
+ 'n/no-unpublished-require': [
55
+ 'error', {
56
+ convertPath: {
57
+ [`${ path.relative(ROOT_DIR, '/opt/nodejs') }/*`]: [ '^(.*?)/opt/nodejs/(.*?)$', 'lambda/layers/$2/nodejs/$2' ],
58
+ },
59
+ },
60
+ ],
61
+ 'n/prefer-global/buffer': [ 'error', 'always' ],
62
+ 'n/prefer-global/console': [ 'error', 'always' ],
63
+ 'n/prefer-global/process': [ 'error', 'always' ],
64
+ 'n/prefer-global/text-decoder': [ 'error', 'never' ],
65
+ 'n/prefer-global/text-encoder': [ 'error', 'never' ],
66
+ 'n/prefer-global/url-search-params': [ 'error', 'never' ],
67
+ 'n/prefer-global/url': [ 'error', 'never' ],
68
+ 'n/prefer-promises/dns': ['error'],
69
+ 'n/prefer-promises/fs': ['error'],
70
+ };
71
+ })();
package/rules/vue.js ADDED
@@ -0,0 +1,14 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ 'unicorn/filename-case': [
6
+ 'error', {
7
+ case: 'pascalCase',
8
+ },
9
+ ],
10
+ 'vue/component-name-in-template-casing': [ 'error', 'kebab-case' ],
11
+ 'vue/component-definition-name-casing': [ 'error', 'kebab-case' ],
12
+ 'vue/singleline-html-element-content-newline': 'off',
13
+ };
14
+ })();
package/rules/yaml.js ADDED
@@ -0,0 +1,27 @@
1
+ (() => {
2
+ 'use strict';
3
+
4
+ module.exports = {
5
+ 'yml/block-sequence': [ 'error', 'always' ],
6
+ 'yml/file-extension': [
7
+ 'error',
8
+ {
9
+ extension: 'yaml',
10
+ caseSensitive: true,
11
+ },
12
+ ],
13
+ 'yml/indent': [
14
+ 'error',
15
+ 2,
16
+ {
17
+ indentBlockSequences: true,
18
+ },
19
+ ],
20
+ 'yml/no-empty-document': ['off'],
21
+ 'yml/quotes': [
22
+ 'error', {
23
+ prefer: 'single',
24
+ },
25
+ ],
26
+ };
27
+ })();
package/plugins/node.js DELETED
@@ -1,75 +0,0 @@
1
- (() => {
2
- 'use strict';
3
-
4
- const path = require('path');
5
-
6
- const NODE_VERSION = '>=14.0.0';
7
- const ROOT_DIR = path.resolve(__dirname, '../../../');
8
-
9
- module.exports = {
10
- 'node/callback-return': [
11
- 'error', [
12
- 'callback',
13
- 'cb',
14
- 'done',
15
- 'next',
16
- ],
17
- ],
18
- // not used because it does not support IIFE
19
- // 'node/global-require': ['error'],
20
- 'node/handle-callback-err': ['error'],
21
- 'node/no-deprecated-api': [
22
- 'error', {
23
- version: NODE_VERSION,
24
- },
25
- ],
26
- 'node/no-missing-import': ['error'],
27
- 'node/no-missing-require': [
28
- 'error', {
29
- allowModules: ['aws-sdk'],
30
- resolvePaths: [path.resolve(__dirname, `${ ROOT_DIR }/lambda/layers/node-modules/nodejs/node_modules`)],
31
- },
32
- ],
33
- 'node/no-mixed-requires': [
34
- 'error', {
35
- allowCall: true,
36
- grouping: true,
37
- },
38
- ],
39
- 'node/no-new-require': ['error'],
40
- 'node/no-path-concat': ['error'],
41
- 'node/no-unsupported-features/es-builtins': [
42
- 'error', {
43
- version: NODE_VERSION,
44
- },
45
- ],
46
- 'node/no-unsupported-features/es-syntax': [
47
- 'error', {
48
- version: NODE_VERSION,
49
- },
50
- ],
51
- 'node/no-unsupported-features/node-builtins': [
52
- 'error', {
53
- version: NODE_VERSION,
54
- },
55
- ],
56
- 'node/no-unpublished-bin': ['error'],
57
- 'node/no-unpublished-import': ['error'],
58
- 'node/no-unpublished-require': [
59
- 'error', {
60
- convertPath: {
61
- [`${ path.relative(ROOT_DIR, '/opt/nodejs') }/*`]: [ '^(.*?)/opt/nodejs/(.*?)$', 'lambda/layers/$2/nodejs/$2' ],
62
- },
63
- },
64
- ],
65
- 'node/prefer-global/buffer': [ 'error', 'always' ],
66
- 'node/prefer-global/console': [ 'error', 'always' ],
67
- 'node/prefer-global/process': [ 'error', 'always' ],
68
- 'node/prefer-global/text-decoder': [ 'error', 'never' ],
69
- 'node/prefer-global/text-encoder': [ 'error', 'never' ],
70
- 'node/prefer-global/url-search-params': [ 'error', 'never' ],
71
- 'node/prefer-global/url': [ 'error', 'never' ],
72
- 'node/prefer-promises/dns': ['error'],
73
- 'node/prefer-promises/fs': ['error'],
74
- };
75
- })();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes