@bedrockio/eslint-plugin 1.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 +31 -0
- package/index.js +19 -0
- package/jest.js +23 -0
- package/mdx.js +19 -0
- package/node-imports.js +37 -0
- package/package.json +45 -0
- package/react.js +32 -0
- package/recommended.js +26 -0
- package/typescript-imports.js +41 -0
- package/webpack-imports.js +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @bedrockio/eslint-plugin
|
|
2
|
+
|
|
3
|
+
Common ESLint plugin for Bedrock projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You'll first need to install [ESLint](http://eslint.org):
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
$ npm i eslint --save-dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Next, install `eslint-plugin-bedrock`:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
$ npm install @bedrockio/eslint-plugin --save-dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
You can now extend from `recommended`, `react`, and `jest` configs.
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"extends": [
|
|
26
|
+
"plugin:bedrock/recommended",
|
|
27
|
+
"plugin:bedrock/jest",
|
|
28
|
+
"plugin:bedrock/react"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as recommended } from './recommended.js';
|
|
2
|
+
import { default as react } from './react.js';
|
|
3
|
+
import { default as jest } from './jest.js';
|
|
4
|
+
import { default as mdx } from './mdx.js';
|
|
5
|
+
import { default as nodeImports } from './node-imports.js';
|
|
6
|
+
import { default as webpackImports } from './webpack-imports.js';
|
|
7
|
+
import { default as typescriptImports } from './typescript-imports.js';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
configs: {
|
|
11
|
+
mdx,
|
|
12
|
+
jest,
|
|
13
|
+
react,
|
|
14
|
+
recommended,
|
|
15
|
+
nodeImports,
|
|
16
|
+
webpackImports,
|
|
17
|
+
typescriptImports,
|
|
18
|
+
},
|
|
19
|
+
};
|
package/jest.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import plugin from 'eslint-plugin-jest';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...plugin.configs['flat/recommended'],
|
|
6
|
+
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
7
|
+
languageOptions: {
|
|
8
|
+
globals: {
|
|
9
|
+
...globals.jest,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
'jest/expect-expect': [
|
|
14
|
+
'error',
|
|
15
|
+
{
|
|
16
|
+
assertFunctionNames: ['expect*', 'assert*'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
'jest/no-focused-tests': 'off',
|
|
20
|
+
'jest/no-disabled-tests': 'off',
|
|
21
|
+
'jest/no-conditional-expect': 'off',
|
|
22
|
+
},
|
|
23
|
+
};
|
package/mdx.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import mdx from 'eslint-plugin-mdx';
|
|
2
|
+
|
|
3
|
+
const plugin = {
|
|
4
|
+
...mdx.flat,
|
|
5
|
+
processor: mdx.createRemarkProcessor({
|
|
6
|
+
lintCodeBlocks: true,
|
|
7
|
+
}),
|
|
8
|
+
rules: {
|
|
9
|
+
...mdx.flat.rules,
|
|
10
|
+
semi: 0,
|
|
11
|
+
'no-undef': 0,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(plugin, 'codeBlocks', {
|
|
16
|
+
value: mdx.flatCodeBlocks,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default plugin;
|
package/node-imports.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import plugin from 'eslint-plugin-import';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
files: ['**/*.{js,jsx}'],
|
|
5
|
+
plugins: {
|
|
6
|
+
import: plugin,
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
'import/no-unresolved': 'warn',
|
|
10
|
+
'import/no-named-as-default-member': 'off',
|
|
11
|
+
'import/order': [
|
|
12
|
+
'warn',
|
|
13
|
+
{
|
|
14
|
+
'newlines-between': 'always-and-inside-groups',
|
|
15
|
+
pathGroups: [
|
|
16
|
+
{
|
|
17
|
+
pattern: 'utils',
|
|
18
|
+
group: 'internal',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pattern: 'utils/**',
|
|
22
|
+
group: 'internal',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
groups: [
|
|
26
|
+
'builtin',
|
|
27
|
+
'external',
|
|
28
|
+
'internal',
|
|
29
|
+
['parent', 'sibling'],
|
|
30
|
+
'index',
|
|
31
|
+
'object',
|
|
32
|
+
'type',
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bedrockio/eslint-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Common ESLint plugin for Bedrock projects.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"eslint",
|
|
9
|
+
"eslintplugin",
|
|
10
|
+
"eslint-plugin"
|
|
11
|
+
],
|
|
12
|
+
"main": "index.js",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@eslint/compat": "^1.0.1",
|
|
15
|
+
"@eslint/js": "^9.2.0",
|
|
16
|
+
"eslint-plugin-import": "^2.29.1",
|
|
17
|
+
"eslint-plugin-jest": "^28.5.0",
|
|
18
|
+
"eslint-plugin-mdx": "^3.1.5",
|
|
19
|
+
"eslint-plugin-react": "^7.34.1",
|
|
20
|
+
"globals": "^15.2.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"eslint": ">=9",
|
|
24
|
+
"eslint-import-resolver-webpack": "^0.13.8"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"eslint-import-resolver-webpack": {
|
|
28
|
+
"optional": true
|
|
29
|
+
},
|
|
30
|
+
"eslint-plugin-react": {
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
"eslint-plugin-mdx": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"eslint": "^9.2.0",
|
|
39
|
+
"eslint-import-resolver-webpack": "^0.13.8"
|
|
40
|
+
},
|
|
41
|
+
"volta": {
|
|
42
|
+
"node": "20.12.2",
|
|
43
|
+
"yarn": "1.22.22"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/react.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import react from 'eslint-plugin-react';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
// This dependency can be removed when this lands:
|
|
5
|
+
// https://github.com/jsx-eslint/eslint-plugin-react/issues/3699
|
|
6
|
+
import { fixupPluginRules } from '@eslint/compat';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
files: ['**/*.{js,jsx}'],
|
|
10
|
+
plugins: {
|
|
11
|
+
react: fixupPluginRules(react),
|
|
12
|
+
},
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parserOptions: {
|
|
15
|
+
ecmaFeatures: {
|
|
16
|
+
jsx: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
globals: {
|
|
20
|
+
...globals.browser,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
...react.configs['recommended'].rules,
|
|
25
|
+
...react.configs['jsx-runtime'].rules,
|
|
26
|
+
},
|
|
27
|
+
settings: {
|
|
28
|
+
react: {
|
|
29
|
+
version: 'detect',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
package/recommended.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
files: ['**/*.{js,jsx}'],
|
|
6
|
+
languageOptions: {
|
|
7
|
+
ecmaVersion: 'latest',
|
|
8
|
+
sourceType: 'module',
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.node,
|
|
11
|
+
...globals.browser,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
...js.configs.recommended.rules,
|
|
16
|
+
semi: 'error',
|
|
17
|
+
'no-console': 'warn',
|
|
18
|
+
curly: ['error', 'multi-line', 'consistent'],
|
|
19
|
+
'no-unused-vars': [
|
|
20
|
+
'warn',
|
|
21
|
+
{
|
|
22
|
+
ignoreRestSiblings: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import plugin from 'eslint-plugin-import';
|
|
2
|
+
|
|
3
|
+
const { parserOptions, ...rest } = plugin.configs.recommended;
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
...rest,
|
|
7
|
+
files: ['**/*.{ts,tsx}'],
|
|
8
|
+
plugins: {
|
|
9
|
+
import: plugin,
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'prefer-const': 'off',
|
|
13
|
+
'import/no-unresolved': 'warn',
|
|
14
|
+
'import/no-named-as-default-member': 'off',
|
|
15
|
+
'import/order': [
|
|
16
|
+
'warn',
|
|
17
|
+
{
|
|
18
|
+
'newlines-between': 'always-and-inside-groups',
|
|
19
|
+
pathGroups: [
|
|
20
|
+
{
|
|
21
|
+
pattern: 'utils',
|
|
22
|
+
group: 'internal',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
pattern: 'utils/**',
|
|
26
|
+
group: 'internal',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
groups: [
|
|
30
|
+
'builtin',
|
|
31
|
+
'external',
|
|
32
|
+
'internal',
|
|
33
|
+
['parent', 'sibling'],
|
|
34
|
+
'index',
|
|
35
|
+
'object',
|
|
36
|
+
'type',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import plugin from 'eslint-plugin-import';
|
|
2
|
+
|
|
3
|
+
const { parserOptions, ...rest } = plugin.configs.recommended;
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
...rest,
|
|
7
|
+
files: ['**/*.{js,jsx}'],
|
|
8
|
+
plugins: {
|
|
9
|
+
import: plugin,
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'import/no-unresolved': 'warn',
|
|
13
|
+
'import/no-named-as-default-member': 'off',
|
|
14
|
+
'import/order': [
|
|
15
|
+
'warn',
|
|
16
|
+
{
|
|
17
|
+
'newlines-between': 'always-and-inside-groups',
|
|
18
|
+
pathGroups: [
|
|
19
|
+
{
|
|
20
|
+
pattern: 'semantic',
|
|
21
|
+
group: 'external',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
pattern: '+(stores|helpers|layouts)',
|
|
25
|
+
group: 'internal',
|
|
26
|
+
position: 'before',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
pattern: '+(stores|helpers|layouts)/**',
|
|
30
|
+
group: 'internal',
|
|
31
|
+
position: 'before',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
pattern: '+(screens|modals|components)',
|
|
35
|
+
group: 'internal',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pattern: '+(screens|modals|components)/**',
|
|
39
|
+
group: 'internal',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
pattern: 'utils',
|
|
43
|
+
group: 'internal',
|
|
44
|
+
position: 'after',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
pattern: 'utils/**',
|
|
48
|
+
group: 'internal',
|
|
49
|
+
position: 'after',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
groups: [
|
|
53
|
+
'builtin',
|
|
54
|
+
'unknown',
|
|
55
|
+
'external',
|
|
56
|
+
'internal',
|
|
57
|
+
['parent', 'sibling'],
|
|
58
|
+
'index',
|
|
59
|
+
'object',
|
|
60
|
+
'type',
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
settings: {
|
|
66
|
+
'import/resolver': 'webpack',
|
|
67
|
+
},
|
|
68
|
+
};
|