@markuplint-dev/eslint-config 1.0.0-alpha.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/.eslintrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@markuplint-dev/eslint-config",
3
+ "rules": {
4
+ "no-restricted-globals": 0,
5
+ "unicorn/prefer-module": 0
6
+ }
7
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # 1.0.0-alpha.1 (2024-06-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **eslint:** add tsconfig for test env ([fecaef8](https://github.com/markuplint/markuplint/commit/fecaef8e4878dba9552e864c83f3ab6e3651ade1))
12
+
13
+
14
+ ### Features
15
+
16
+ * **eslint:** moved ESLint configuration to `@markuplint-dev/eslint-config` ([642d887](https://github.com/markuplint/markuplint/commit/642d887be920e610617fc93abb13db7c7f21eb70))
package/base.js ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @type {import('eslint').Linter.Config}
3
+ */
4
+ module.exports = {
5
+ extends: [
6
+ 'eslint:recommended',
7
+ 'plugin:unicorn/recommended',
8
+ 'plugin:regexp/recommended',
9
+ 'plugin:import/recommended',
10
+ 'plugin:@eslint-community/eslint-comments/recommended',
11
+ 'plugin:import/typescript',
12
+ ],
13
+ env: {
14
+ browser: false,
15
+ es6: true,
16
+ node: true,
17
+ commonjs: false,
18
+ },
19
+ plugins: ['unicorn', '@typescript-eslint', 'jsdoc', 'import', 'sort-class-members'],
20
+ parserOptions: {
21
+ ecmaVersion: 13,
22
+ },
23
+ rules: {
24
+ indent: 0,
25
+ quotes: [2, 'single', 'avoid-escape'],
26
+ 'no-var': 2,
27
+ 'prefer-const': 2,
28
+ 'no-dupe-class-members': 0,
29
+ 'no-unused-vars': 0,
30
+ 'no-array-constructor': 0,
31
+ 'sort-imports': 0,
32
+ 'no-console': [1],
33
+ 'no-mixed-spaces-and-tabs': 0,
34
+ 'require-await': 2,
35
+ 'lines-between-class-members': [1, 'always', { exceptAfterSingleLine: true }],
36
+ 'no-restricted-globals': [2, '__dirname', 'require'],
37
+
38
+ 'node/no-unsupported-features/es-syntax': 0,
39
+
40
+ 'unicorn/consistent-destructuring': 0,
41
+ 'unicorn/consistent-function-scoping': 0,
42
+ 'unicorn/no-array-callback-reference': 0,
43
+ 'unicorn/no-nested-ternary': 0,
44
+ 'unicorn/no-null': 0,
45
+ 'unicorn/prefer-query-selector': 0,
46
+ 'unicorn/prefer-ternary': 0,
47
+ 'unicorn/prevent-abbreviations': 0,
48
+
49
+ '@eslint-community/eslint-comments/no-unused-disable': 'error',
50
+
51
+ 'import/no-named-as-default': 0,
52
+ 'import/no-default-export': 2,
53
+ 'import/order': [
54
+ 'error',
55
+ {
56
+ groups: ['type', 'builtin', 'external', 'parent', 'sibling', 'index', 'object'],
57
+ pathGroups: [
58
+ {
59
+ pattern: '@alias/**',
60
+ group: 'parent',
61
+ position: 'before',
62
+ },
63
+ ],
64
+ alphabetize: {
65
+ order: 'asc',
66
+ },
67
+ 'newlines-between': 'always',
68
+ },
69
+ ],
70
+ 'import/no-extraneous-dependencies': 2,
71
+
72
+ 'sort-class-members/sort-class-members': [
73
+ 1,
74
+ {
75
+ order: [
76
+ '[static-properties]',
77
+ '[static-methods]',
78
+ '[properties]',
79
+ '[conventional-private-properties]',
80
+ 'constructor',
81
+ '[methods]',
82
+ '[conventional-private-methods]',
83
+ ],
84
+ accessorPairPositioning: 'getThenSet',
85
+ },
86
+ ],
87
+ },
88
+ settings: {
89
+ jsdoc: {
90
+ tagNamePreference: {
91
+ param: 'arg',
92
+ returns: 'return',
93
+ },
94
+ },
95
+ 'import/parsers': {
96
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
97
+ },
98
+ 'import/resolver': {
99
+ typescript: {
100
+ alwaysTryTypes: true,
101
+ project: ['packages/*/tsconfig.json'],
102
+ },
103
+ },
104
+ },
105
+ };
package/index.js ADDED
@@ -0,0 +1,52 @@
1
+ const base = require('./base');
2
+ const parser = require('./parser');
3
+ const test = require('./test');
4
+ const ts = require('./ts');
5
+
6
+ /**
7
+ * @type {import('eslint').Linter.Config}
8
+ */
9
+ module.exports = {
10
+ ...base,
11
+ overrides: [
12
+ {
13
+ files: ['{*,**/*}.{ts,tsx,cts,mts}'],
14
+ ...mergeConfig(base, ts),
15
+ },
16
+ {
17
+ files: ['./packages/@markuplint/**/parser.ts'],
18
+ ...mergeConfig(base, ts, parser),
19
+ },
20
+ {
21
+ files: ['{*,**/*}.spec.{js,mjs,cjs,ts}', 'vitest.config.ts'],
22
+ ...mergeConfig(base, ts, test),
23
+ },
24
+ {
25
+ files: ['packages/@markuplint/create-rule/scaffold/**/*'],
26
+ ...mergeConfig(base, ts, test, {
27
+ rules: {
28
+ 'unicorn/filename-case': 0,
29
+ },
30
+ }),
31
+ },
32
+ ],
33
+ };
34
+
35
+ /**
36
+ *
37
+ * @param {import('eslint').Linter.Config[]} configs
38
+ * @returns {import('eslint').Linter.Config}
39
+ */
40
+ function mergeConfig(...configs) {
41
+ function mergeConfig(a, b) {
42
+ return {
43
+ ...a,
44
+ ...b,
45
+ rules: {
46
+ ...a.rules,
47
+ ...b.rules,
48
+ },
49
+ };
50
+ }
51
+ return configs.reduce(mergeConfig);
52
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@markuplint-dev/eslint-config",
3
+ "version": "1.0.0-alpha.1",
4
+ "description": "ESLint and config for Markuplint projects",
5
+ "repository": "git@github.com:markuplint/markuplint.git",
6
+ "author": "Yusuke Hirao <yusukehirao@me.com>",
7
+ "license": "MIT",
8
+ "private": false,
9
+ "type": "commonjs",
10
+ "main": "index.js",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "dependencies": {
15
+ "@eslint-community/eslint-plugin-eslint-comments": "4.3.0",
16
+ "@typescript-eslint/eslint-plugin": "7.11.0",
17
+ "@typescript-eslint/parser": "7.11.0",
18
+ "eslint": "8.57.0",
19
+ "eslint-import-resolver-typescript": "3.6.1",
20
+ "eslint-plugin-import": "2.29.1",
21
+ "eslint-plugin-jsdoc": "48.2.7",
22
+ "eslint-plugin-n": "17.7.0",
23
+ "eslint-plugin-regexp": "2.6.0",
24
+ "eslint-plugin-sort-class-members": "1.20.0",
25
+ "eslint-plugin-unicorn": "51.0.1"
26
+ },
27
+ "gitHead": "b1cabc178e3553fd66c7ed4357b4124eb2585327"
28
+ }
package/parser.js ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @type {import('eslint').Linter.Config}
3
+ */
4
+ module.exports = {
5
+ rules: {
6
+ 'sort-class-members/sort-class-members': [
7
+ 1,
8
+ {
9
+ order: [
10
+ '[static-properties]',
11
+ '[static-methods]',
12
+ '[properties]',
13
+ '[conventional-private-properties]',
14
+ 'constructor',
15
+ '[accessor-pairs]',
16
+ '[perser-methods-main]',
17
+ '[perser-methods-visit]',
18
+ '[perser-methods-update]',
19
+ '[perser-methods-detection]',
20
+ '[perser-methods-creation]',
21
+ '[perser-methods-manipurate]',
22
+ '[other-methods]',
23
+ '[conventional-private-methods]',
24
+ '[other-native-private-methods]',
25
+ ],
26
+ groups: {
27
+ 'perser-methods-main': [
28
+ { name: 'tokenize', type: 'method' },
29
+ { name: 'beforeParse', type: 'method' },
30
+ { name: 'parse', type: 'method' },
31
+ { name: 'afterParse', type: 'method' },
32
+ { name: 'parseError', type: 'method' },
33
+ { name: 'traverse', type: 'method' },
34
+ { name: 'afterTraverse', type: 'method' },
35
+ { name: 'nodeize', type: 'method' },
36
+ { name: 'afterNodeize', type: 'method' },
37
+ { name: 'flattenNodes', type: 'method' },
38
+ { name: 'afterFlattenNodes', type: 'method' },
39
+ ],
40
+ 'perser-methods-visit': [
41
+ { name: 'visitDoctype', type: 'method' },
42
+ { name: 'visitComment', type: 'method' },
43
+ { name: 'visitText', type: 'method' },
44
+ { name: 'visitElement', type: 'method' },
45
+ { name: 'visitPsBlock', type: 'method' },
46
+ { name: 'visitChildren', type: 'method' },
47
+ { name: 'visitSpreadAttr', type: 'method' },
48
+ { name: 'visitAttr', type: 'method' },
49
+ { name: 'parseCodeFragment', type: 'method' },
50
+ ],
51
+ 'perser-methods-update': [
52
+ { name: 'updateLocation', type: 'method' },
53
+ { name: 'updateRaw', type: 'method' },
54
+ { name: 'updateElement', type: 'method' },
55
+ { name: 'updateAttr', type: 'method' },
56
+ ],
57
+ 'perser-methods-detection': [
58
+ //
59
+ { name: 'detectElementType', type: 'method' },
60
+ ],
61
+ 'perser-methods-creation': [
62
+ { name: 'createToken', type: 'method' },
63
+ { name: 'sliceFragment', type: 'method' },
64
+ { name: 'getOffsetsFromCode', type: 'method' },
65
+ ],
66
+ 'perser-methods-manipurate': [
67
+ { name: 'walk', type: 'method' },
68
+ { name: 'appendChild', type: 'method' },
69
+ { name: 'replaceChild', type: 'method' },
70
+ ],
71
+ 'other-methods': [
72
+ {
73
+ type: 'method',
74
+ kind: 'nonAccessor',
75
+ static: false,
76
+ accessibility: 'public',
77
+ sort: 'alphabetical',
78
+ },
79
+ ],
80
+ 'other-native-private-methods': [
81
+ {
82
+ name: '/^#/',
83
+ type: 'method',
84
+ kind: 'nonAccessor',
85
+ static: false,
86
+ accessibility: 'private',
87
+ sort: 'alphabetical',
88
+ },
89
+ ],
90
+ },
91
+ accessorPairPositioning: 'getThenSet',
92
+ },
93
+ ],
94
+ '@typescript-eslint/member-ordering': 0,
95
+ },
96
+ };
package/test.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @type {import('eslint').Linter.Config}
3
+ */
4
+ module.exports = {
5
+ rules: {
6
+ 'unicorn/error-message': 0,
7
+ 'unicorn/no-await-expression-member': 0,
8
+ 'unicorn/text-encoding-identifier-case': 0,
9
+ 'import/no-extraneous-dependencies': 0,
10
+ '@typescript-eslint/no-var-requires': 0,
11
+ '@typescript-eslint/prefer-readonly-parameter-types': 0,
12
+ },
13
+ };
package/ts.js ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @type {import('eslint').Linter.Config}
3
+ */
4
+ module.exports = {
5
+ parser: '@typescript-eslint/parser',
6
+ parserOptions: {
7
+ sourceType: 'module',
8
+ project: ['./tsconfig.json', './tsconfig.test.json'],
9
+ },
10
+ rules: {
11
+ '@typescript-eslint/no-unused-vars': [2, { args: 'none' }],
12
+ '@typescript-eslint/no-array-constructor': 2,
13
+ '@typescript-eslint/adjacent-overload-signatures': 2,
14
+ '@typescript-eslint/no-namespace': [2, { allowDeclarations: true }],
15
+ '@typescript-eslint/prefer-namespace-keyword': 2,
16
+ '@typescript-eslint/no-var-requires': 2,
17
+ '@typescript-eslint/no-unnecessary-type-assertion': 2,
18
+ '@typescript-eslint/restrict-plus-operands': 0,
19
+ '@typescript-eslint/consistent-type-imports': 1,
20
+ '@typescript-eslint/require-await': 'error',
21
+ '@typescript-eslint/no-floating-promises': 'error',
22
+ '@typescript-eslint/strict-boolean-expressions': [
23
+ 'error',
24
+ {
25
+ allowString: true,
26
+ allowNumber: false,
27
+ allowNullableObject: true,
28
+ allowNullableEnum: false,
29
+ allowNullableString: true,
30
+ allowNullableBoolean: true,
31
+ allowAny: true,
32
+ },
33
+ ],
34
+ '@typescript-eslint/member-ordering': [
35
+ 'warn',
36
+ {
37
+ default: 'never',
38
+ classes: {
39
+ memberTypes: [
40
+ 'public-static-field',
41
+ 'protected-static-field',
42
+ 'private-static-field',
43
+ 'public-static-method',
44
+ 'protected-static-method',
45
+ 'public-static-get',
46
+ 'protected-static-get',
47
+ 'private-static-get',
48
+ 'public-instance-field',
49
+ 'protected-instance-field',
50
+ 'private-instance-field',
51
+ 'public-abstract-field',
52
+ 'protected-abstract-field',
53
+ 'public-constructor',
54
+ 'protected-constructor',
55
+ 'private-constructor',
56
+ ['public-abstract-get', 'public-abstract-set'],
57
+ ['protected-abstract-get', 'protected-abstract-set'],
58
+ ['public-instance-get', 'public-instance-set'],
59
+ ['protected-instance-get', 'protected-instance-set'],
60
+ ['private-instance-get', 'private-instance-set'],
61
+ 'public-abstract-method',
62
+ 'protected-abstract-method',
63
+ 'public-instance-method',
64
+ 'protected-instance-method',
65
+ 'private-instance-method',
66
+ 'private-static-method',
67
+ ],
68
+ order: 'alphabetically',
69
+ },
70
+ },
71
+ ],
72
+ '@typescript-eslint/prefer-readonly-parameter-types': [
73
+ 'warn',
74
+ {
75
+ checkParameterProperties: false,
76
+ ignoreInferredTypes: true,
77
+ treatMethodsAsReadonly: false,
78
+ },
79
+ ],
80
+ },
81
+ };