eslint-config-simplesense 4.0.6 → 5.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
@@ -38,5 +38,5 @@ npm install
38
38
  npm run lint
39
39
  npm run test
40
40
  npm run docs:dev
41
- # navigate to the URL provided by Vuepress
41
+ # navigate to the URL provided by Vitepress
42
42
  ```
@@ -1,11 +1,11 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-array-func';
3
2
 
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
- })();
3
+ import rules from '../rules/array-func.js';
4
+
5
+ export default {
6
+ name: 'simplesense/array-func',
7
+ plugins: {
8
+ 'array-func': plugin,
9
+ },
10
+ rules,
11
+ };
@@ -1,13 +1,9 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from '@eslint-community/eslint-plugin-eslint-comments';
3
2
 
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
- })();
3
+ export default {
4
+ name: 'simplesense/eslint-comments',
5
+ plugins: {
6
+ '@eslint-community/eslint-comments': plugin,
7
+ },
8
+ rules: plugin.configs.recommended.rules,
9
+ };
package/config/eslint.js CHANGED
@@ -1,15 +1,11 @@
1
- (() => {
2
- 'use strict';
1
+ import js from '@eslint/js';
3
2
 
4
- const {
5
- configs,
6
- } = require('@eslint/js');
3
+ import rules from '../rules/eslint-recommended.js';
7
4
 
8
- module.exports = {
9
- name: 'simplesense/eslint',
10
- rules: {
11
- ...configs.recommended.rules,
12
- ...require('../rules/eslint-recommended'),
13
- },
14
- };
15
- })();
5
+ export default {
6
+ name: 'simplesense/eslint',
7
+ rules: {
8
+ ...js.configs.recommended.rules,
9
+ ...rules,
10
+ },
11
+ };
@@ -0,0 +1,21 @@
1
+ import globals from 'globals';
2
+
3
+ const vitest = {
4
+ vi: true,
5
+ describe: true,
6
+ it: true,
7
+ expect: true,
8
+ beforeEach: true,
9
+ afterEach: true,
10
+ beforeAll: true,
11
+ afterAll: true,
12
+ spyFn: true,
13
+ };
14
+
15
+ export default {
16
+ ...globals.browser,
17
+ ...globals.es2021,
18
+ ...globals.es6,
19
+ ...globals.node,
20
+ ...vitest,
21
+ };
package/config/import.js CHANGED
@@ -1,11 +1,27 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-import';
3
2
 
4
- module.exports = {
5
- name: 'simplesense/import',
6
- plugins: {
7
- import: require('eslint-plugin-import'),
3
+ import rules from '../rules/import.js';
4
+
5
+ export default {
6
+ name: 'simplesense/import',
7
+ plugins: {
8
+ import: plugin,
9
+ },
10
+ rules,
11
+ // ERROR: parserPath or languageOptions.parser is required!
12
+ // see https://github.com/import-js/eslint-plugin-import/issues/2556
13
+ languageOptions: {
14
+ parserOptions: {
15
+ ecmaVersion: 'latest',
16
+ sourceType: 'module',
17
+ },
18
+ },
19
+ settings: {
20
+ 'import/parsers': {
21
+ espree: ['.js'],
22
+ },
23
+ 'import/resolver': {
24
+ node: true,
8
25
  },
9
- rules: require('../rules/import'),
10
- };
11
- })();
26
+ },
27
+ };
package/config/node.js CHANGED
@@ -1,25 +1,29 @@
1
- (() => {
2
- 'use strict';
1
+ import path from 'node:path';
2
+ import {
3
+ fileURLToPath,
4
+ } from 'node:url';
3
5
 
4
- const path = require('path');
6
+ import plugin from 'eslint-plugin-n';
5
7
 
6
- const ROOT_DIR = path.resolve(__dirname, '../../../'); // this will be in <PROJECT>/node_modules/eslint-config-simplesense/rules/
7
- const NODE_VERSION = '>=16.0.0';
8
+ import rules from '../rules/node.js';
8
9
 
9
- module.exports = {
10
- name: 'simplesense/node',
11
- plugins: {
12
- n: require('eslint-plugin-n'),
13
- },
14
- rules: require('../rules/node'),
15
- settings: {
16
- n: {
17
- allowModules: ['aws-sdk'],
18
- convertPath: {
19
- [`${ path.relative(ROOT_DIR, '/opt/nodejs') }/*`]: [ '^(.*?)/opt/nodejs/(.*?)$', 'lambda/layers/$2/nodejs/$2' ],
20
- },
21
- version: NODE_VERSION,
10
+ const DIRNAME = path.dirname(fileURLToPath(import.meta.url));
11
+ const ROOT_DIR = path.resolve(DIRNAME, '../../../'); // this will be in <PROJECT>/node_modules/eslint-config-simplesense/rules/
12
+ const NODE_VERSION = '>=18.0.0';
13
+
14
+ export default {
15
+ name: 'simplesense/node',
16
+ plugins: {
17
+ n: plugin,
18
+ },
19
+ rules,
20
+ settings: {
21
+ n: {
22
+ allowModules: ['aws-sdk'],
23
+ convertPath: {
24
+ [`${ path.relative(ROOT_DIR, '/opt/nodejs') }/*`]: [ '^(.*?)/opt/nodejs/(.*?)$', 'lambda/layers/$2/nodejs/$2' ],
22
25
  },
26
+ version: NODE_VERSION,
23
27
  },
24
- };
25
- })();
28
+ },
29
+ };
@@ -1,13 +1,9 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-optimize-regex';
3
2
 
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
- })();
3
+ export default {
4
+ name: 'simplesense/optimize-regex',
5
+ plugins: {
6
+ 'optimize-regex': plugin,
7
+ },
8
+ rules: plugin.configs.recommended.rules,
9
+ };
package/config/regexp.js CHANGED
@@ -1,13 +1,9 @@
1
- (() => {
2
- 'use strict';
1
+ import {
2
+ configs,
3
+ } from 'eslint-plugin-regexp';
3
4
 
4
- const {
5
- configs,
6
- } = require('eslint-plugin-regexp');
5
+ const config = {
6
+ ...configs['flat/recommended'],
7
+ };
7
8
 
8
- const config = {
9
- ...configs['flat/recommended'],
10
- };
11
-
12
- module.exports = config;
13
- })();
9
+ export default config;
@@ -1,11 +1,11 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-security';
3
2
 
4
- module.exports = {
5
- name: 'simplesense/security',
6
- plugins: {
7
- security: require('eslint-plugin-security'),
8
- },
9
- rules: require('../rules/security'),
10
- };
11
- })();
3
+ import rules from '../rules/security.js';
4
+
5
+ export default {
6
+ name: 'simplesense/security',
7
+ plugins: {
8
+ security: plugin,
9
+ },
10
+ rules,
11
+ };
package/config/sonarjs.js CHANGED
@@ -1,16 +1,14 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-sonarjs';
3
2
 
4
- const plugin = require('eslint-plugin-sonarjs');
3
+ import rules from '../rules/sonarjs.js';
5
4
 
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
- })();
5
+ export default {
6
+ name: 'simplesense/sonarjs',
7
+ plugins: {
8
+ sonarjs: plugin,
9
+ },
10
+ rules: {
11
+ ...plugin.configs.recommended.rules,
12
+ ...rules,
13
+ },
14
+ };
@@ -0,0 +1,11 @@
1
+ import plugin from '@stylistic/eslint-plugin-js';
2
+
3
+ import rules from '../rules/stylistic.js';
4
+
5
+ export default {
6
+ name: 'simplesense/stylistic',
7
+ plugins: {
8
+ '@stylistic/js': plugin,
9
+ },
10
+ rules,
11
+ };
package/config/unicorn.js CHANGED
@@ -1,11 +1,11 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-unicorn';
3
2
 
4
- module.exports = {
5
- name: 'simplesense/unicorn',
6
- plugins: {
7
- unicorn: require('eslint-plugin-unicorn'),
8
- },
9
- rules: require('../rules/unicorn'),
10
- };
11
- })();
3
+ import rules from '../rules/unicorn.js';
4
+
5
+ export default {
6
+ name: 'simplesense/unicorn',
7
+ plugins: {
8
+ unicorn: plugin,
9
+ },
10
+ rules,
11
+ };
package/config/vue.js CHANGED
@@ -1,17 +1,15 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-vue';
3
2
 
4
- const plugin = require('eslint-plugin-vue');
3
+ import rules from '../rules/vue.js';
5
4
 
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'),
5
+ export default [
6
+ ...plugin.configs['flat/vue2-strongly-recommended'],
7
+ {
8
+ name: 'simplesense/vue',
9
+ files: [ '*.vue', '**/*.vue' ],
10
+ plugins: {
11
+ vue: plugin,
15
12
  },
16
- ];
17
- })();
13
+ rules,
14
+ },
15
+ ];
package/config/yaml.js CHANGED
@@ -1,17 +1,20 @@
1
- (() => {
2
- 'use strict';
1
+ import plugin from 'eslint-plugin-yml';
3
2
 
4
- const plugin = require('eslint-plugin-yml');
3
+ import rules from '../rules/yaml.js';
5
4
 
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'),
5
+ export default [
6
+ ...plugin.configs['flat/standard'],
7
+ {
8
+ name: 'simplesense/yaml',
9
+ files: [
10
+ '*.yaml',
11
+ '**/*.yaml',
12
+ '*.yml',
13
+ '**/*.yml',
14
+ ],
15
+ plugins: {
16
+ yaml: plugin,
15
17
  },
16
- ];
17
- })();
18
+ rules,
19
+ },
20
+ ];
package/index.js CHANGED
@@ -1,56 +1,51 @@
1
- (() => {
2
- 'use strict';
1
+ import eslintConfig from './config/eslint.js';
2
+ import arrayFuncConfig from './config/array-func.js';
3
+ import eslintCommentsConfig from './config/eslint-comments.js';
4
+ import globals from './config/globals.js';
5
+ import importConfig from './config/import.js';
6
+ import nodeConfig from './config/node.js';
7
+ import optimizeRegexConfig from './config/optimize-regex.js';
8
+ import regexpConfig from './config/regexp.js';
9
+ import securityConfig from './config/security.js';
10
+ import sonarJsConfig from './config/sonarjs.js';
11
+ import stylisticConfig from './config/stylistic.js';
12
+ import unicornConfig from './config/unicorn.js';
13
+ import vueConfig from './config/vue.js';
14
+ import yamlConfig from './config/yaml.js';
3
15
 
4
- const globals = require('globals');
5
-
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
- }
12
-
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,
37
- },
38
- },
39
- },
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
- ],
16
+ export default [
17
+ eslintConfig,
18
+ arrayFuncConfig,
19
+ eslintCommentsConfig,
20
+ importConfig,
21
+ nodeConfig,
22
+ optimizeRegexConfig,
23
+ regexpConfig,
24
+ securityConfig,
25
+ stylisticConfig,
26
+ sonarJsConfig,
27
+ unicornConfig,
28
+ ...vueConfig, // exports an array
29
+ ...yamlConfig, // exports an array
30
+ {
31
+ languageOptions: {
32
+ sourceType: 'module',
33
+ globals,
54
34
  },
55
- ];
56
- })();
35
+ },
36
+ {
37
+ // it's a bit confusing, but this needs to be in a config all by itself
38
+ // https://github.com/eslint/eslint/issues/17400
39
+ ignores: [
40
+ '!.*',
41
+ '.cache/',
42
+ '.git/',
43
+ '.github/actions/',
44
+ '.npm/',
45
+ 'coverage/',
46
+ 'lib-cov/',
47
+ 'node_modules/',
48
+ '**/*.min.*',
49
+ ],
50
+ },
51
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-simplesense",
3
- "version": "4.0.6",
3
+ "version": "5.0.0",
4
4
  "description": "ESLint Config for Simplesense Styles",
5
5
  "keywords": [
6
6
  "eslint",
@@ -17,6 +17,10 @@
17
17
  "url": "git+https://github.com/simplesenseio/eslint-config-simplesense.git"
18
18
  },
19
19
  "license": "Apache-2.0",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": "./index.js"
23
+ },
20
24
  "main": "index.js",
21
25
  "files": [
22
26
  "index.js",
@@ -27,7 +31,7 @@
27
31
  "configs:build": "node scripts/generate-configs.js",
28
32
  "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
33
  "docs:build": "vitepress build docs",
30
- "docs:clean": "rm -rf docs/.vitepress/dist ./dist",
34
+ "docs:clean": "rm -rf ./docs/rules ./docs/.vitepress/dist ./docs/.vitepress/sidebar.json ./docs/.vitepress/cache ./dist",
31
35
  "docs:dev": "npm run docs:clean && npm run docs:generate && npm run vitepress:sidebar && vitepress dev docs",
32
36
  "docs:generate": "node scripts/generate-docs.js",
33
37
  "docs:mv": "mv docs/.vitepress/dist ./",
@@ -36,40 +40,16 @@
36
40
  "lint:eslint": "eslint --fix '**/*.{mjs,js,vue,yaml,yml}'",
37
41
  "lint:package-json": "sort-package-json",
38
42
  "pretest": "npm run configs:build",
39
- "test": "NODE_OPTIONS=\"${NODE_OPTIONS} --experimental-vm-modules\" jest",
43
+ "test": "vitest --run",
40
44
  "vitepress:sidebar": "node scripts/generate-vitepress-sidebar.js"
41
45
  },
42
- "jest": {
43
- "collectCoverage": true,
44
- "collectCoverageFrom": [
45
- "index.js",
46
- "config/*.js",
47
- "rules/*.js"
48
- ],
49
- "moduleNameMapper": {
50
- "eslint/use-at-your-own-risk": "eslint/lib/unsupported-api"
51
- },
52
- "reporters": [
53
- "default",
54
- "github-actions"
55
- ],
56
- "setupFiles": [
57
- "<rootDir>/test/setup/global-functions.js"
58
- ],
59
- "testPathIgnorePatterns": [
60
- "/node_modules/",
61
- "<rootDir>/\\.github/"
62
- ],
63
- "verbose": true
64
- },
65
46
  "dependencies": {
66
47
  "@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
67
48
  "@eslint/js": "^9.8.0",
68
- "core-js": "^3.38.0",
69
- "eslint-plugin-array-func": "^4.0.0",
49
+ "@stylistic/eslint-plugin-js": "^2.6.1",
50
+ "eslint-plugin-array-func": "^5.0.2",
70
51
  "eslint-plugin-import": "^2.29.1",
71
- "eslint-plugin-n": "^17.4.0",
72
- "eslint-plugin-no-use-extend-native": "^0.5.0",
52
+ "eslint-plugin-n": "^17.10.2",
73
53
  "eslint-plugin-optimize-regex": "^1.2.1",
74
54
  "eslint-plugin-regexp": "^2.6.0",
75
55
  "eslint-plugin-security": "^3.0.1",
@@ -80,10 +60,11 @@
80
60
  "globals": "^15.9.0"
81
61
  },
82
62
  "devDependencies": {
63
+ "@vitest/coverage-v8": "^2.0.5",
83
64
  "eslint": "^8.57.0",
84
- "jest": "^29.7.0",
85
65
  "sort-package-json": "^2.10.0",
86
- "vitepress": "^1.3.2"
66
+ "vitepress": "^1.3.2",
67
+ "vitest": "^2.0.5"
87
68
  },
88
69
  "peerDependencies": {
89
70
  "eslint": "8.x"
@@ -1,10 +1,6 @@
1
- (() => {
2
- 'use strict';
3
-
4
- module.exports = {
5
- 'array-func/avoid-reverse': ['error'],
6
- 'array-func/no-unnecessary-this-arg': ['error'],
7
- 'array-func/prefer-flat': ['error'],
8
- 'array-func/prefer-flat-map': ['error'],
9
- };
10
- })();
1
+ export default {
2
+ 'array-func/avoid-reverse': ['error'],
3
+ 'array-func/no-unnecessary-this-arg': ['error'],
4
+ 'array-func/prefer-flat': ['error'],
5
+ 'array-func/prefer-flat-map': ['error'],
6
+ };