power-linter 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 ADDED
@@ -0,0 +1,78 @@
1
+ # power-linter
2
+
3
+ power-linter — собственный линтер (ESLint) и форматтер (Prettier) с расширяемой архитектурой для произвольных правил.
4
+
5
+ - конфиги eslint и prettier из коробки
6
+ - кастомные правила-линтера (see `eslint-plugin-rules`)
7
+
8
+ ## Использование
9
+
10
+ 1. Установка:
11
+
12
+ ```bash
13
+ npm install power-linter
14
+ ```
15
+
16
+ 2. Добавьте экспорт конфигурации eslint
17
+
18
+ ```js
19
+ // .eslintrc.js
20
+ module.exports = require('power-linter/src/eslint/config');
21
+ ```
22
+
23
+ 3. Добавьте экспорт конфигурации Prettier
24
+
25
+ ```js
26
+ // .prettierrc.js
27
+ module.exports = require('power-linter/src/prettier/config');
28
+ ```
29
+
30
+ 4. Для кастомных правил добавляйте файлы в `eslint-plugin-rules`
31
+
32
+ 5. Добавьте в корневой каталог проекта настройки vscode в каталоге .vscode создайте файл settings.json и добавьте в него
33
+
34
+ `{
35
+ "eslint.enable": true,
36
+ "eslint.validate": [
37
+ "javascript",
38
+ "javascriptreact",
39
+ "typescript",
40
+ "typescriptreact"
41
+ ],
42
+ "eslint.run": "onType",
43
+ "editor.codeActionsOnSave": {
44
+ "source.fixAll.eslint": "explicit"
45
+ },
46
+ "editor.formatOnSave": true,
47
+ "[javascript]": {
48
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
49
+ "editor.formatOnSave": true
50
+ },
51
+ "[javascriptreact]": {
52
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
53
+ "editor.formatOnSave": true
54
+ },
55
+ "[typescript]": {
56
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
57
+ "editor.formatOnSave": true
58
+ },
59
+ "[typescriptreact]": {
60
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
61
+ "editor.formatOnSave": true
62
+ },
63
+ "eslint.lintTask.enable": true,
64
+ "eslint.workingDirectories": [
65
+ {
66
+ "mode": "auto"
67
+ }
68
+ ]
69
+ }`
70
+
71
+ 6. Для запускаемых скриптов добавьте команды в package.json проекта
72
+ `
73
+ "format": "cd power-linter && npm run format --prefix . && cd ..",
74
+ "lint": "cd power-linter && npm run lint --prefix . && cd ..",
75
+ "codemod:classToFC": "cd power-linter && npm run codemod:classToFC --prefix . --",
76
+ `
77
+
78
+ ---
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "power-linter",
3
+ "version": "1.0.0",
4
+ "description": "power-linter — линтер (ESLint) и форматтер (Prettier) с расширяемой архитектурой для произвольных правил.",
5
+ "main": "src/index.js",
6
+ "author": "vollmond148259",
7
+ "license": "MIT",
8
+ "keywords": [
9
+ "eslint",
10
+ "prettier",
11
+ "linter",
12
+ "config",
13
+ "eslint-plugin",
14
+ "eslint-config",
15
+ "eslint-rules",
16
+ "custom-rules",
17
+ "code-style"
18
+ ],
19
+ "dependencies": {
20
+ "eslint": "^8.56.0",
21
+ "prettier": "^3.2.5",
22
+ "@babel/eslint-parser": "^7.19.1",
23
+ "eslint-config-airbnb": "^19.0.4",
24
+ "eslint-config-prettier": "^8.5.0",
25
+ "eslint-plugin-rules": "file:./eslint-plugin-rules",
26
+ "eslint-plugin-import": "^2.26.0",
27
+ "eslint-plugin-jsx-a11y": "^6.6.0",
28
+ "eslint-plugin-react": "^7.30.1",
29
+ "eslint-plugin-react-hooks": "^4.6.0"
30
+ },
31
+ "peerDependencies": {
32
+ "eslint": "^8.0.0"
33
+ },
34
+ "files": [
35
+ "src/"
36
+ ],
37
+ "scripts": {
38
+ "lint": "eslint . --ext .js,.jsx,.ts,.tsx --config src/eslint/config.js",
39
+ "format": "prettier --write .",
40
+ "codemod:classToFC": "node scripts/classToFC/run-codemod.js"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/Vollmond148259/power-linter.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/Vollmond148259/power-linter/issues"
48
+ },
49
+ "homepage": "https://github.com/Vollmond148259/power-linter#readme"
50
+ }
@@ -0,0 +1,63 @@
1
+ module.exports = {
2
+ root: true,
3
+ env: {
4
+ browser: true,
5
+ node: true,
6
+ es2021: true,
7
+ },
8
+ extends: ['airbnb', 'airbnb/hooks', 'eslint:recommended', 'prettier', 'plugin:rules/recommended'],
9
+ parser: '@babel/eslint-parser',
10
+ parserOptions: {
11
+ requireConfigFile: false,
12
+ },
13
+ globals: {
14
+ document: true,
15
+ localStorage: true,
16
+ Headers: true,
17
+ fetch: true,
18
+ },
19
+ rules: {
20
+ 'no-continue': 0,
21
+ 'consistent-return': 0,
22
+ 'no-constant-condition': 0,
23
+ 'arrow-parens': 0,
24
+ 'no-else-return': 0,
25
+ 'global-require': 0,
26
+ 'max-len': ['error', { code: 120, ignorePattern: '^import\\W.*' }],
27
+ 'linebreak-style': 0,
28
+ indent: 0,
29
+ 'prefer-template': ['warn'],
30
+ 'no-restricted-syntax': 0,
31
+ 'no-prototype-builtins': 0,
32
+ 'no-param-reassign': ['error', { props: false }],
33
+ 'comma-dangle': ['error', 'only-multiline'],
34
+ 'no-undef': 0,
35
+ 'no-shadow': 0,
36
+ 'no-plusplus': 0,
37
+ 'arrow-body-style': ['error', 'as-needed'],
38
+ 'default-param-last': 0,
39
+ 'class-methods-use-this': ['error', { enforceForClassFields: false }],
40
+ 'no-use-before-define': ['error', { functions: false, classes: true, variables: true }],
41
+ 'no-useless-escape': 'warn',
42
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
43
+ 'func-names': 0,
44
+ 'jsx-a11y/anchor-is-valid': ['warn'],
45
+ 'jsx-a11y/no-static-element-interactions': 0,
46
+ 'jsx-a11y/click-events-have-key-events': ['warn'],
47
+ 'import/prefer-default-export': 0,
48
+ 'import/extensions': ['warn', { jsx: 'never' }],
49
+ 'import/no-unresolved': 0,
50
+ 'import/no-extraneous-dependencies': 0,
51
+ 'react/jsx-curly-brace-presence': 0,
52
+ 'react/jsx-filename-extension': ['warn', { extensions: ['.js', '.jsx'] }],
53
+ 'react/require-default-props': 0,
54
+ 'react/jsx-curly-spacing': 0,
55
+ 'react/jsx-indent': ['error', 4],
56
+ 'react/jsx-indent-props': 0,
57
+ 'react/forbid-prop-types': 0,
58
+ 'react/sort-comp': 0,
59
+ 'react/prop-types': 0,
60
+ 'react/jsx-props-no-spreading': 0,
61
+ 'react/jsx-no-bind': 0
62
+ },
63
+ };
package/src/index.js ADDED
@@ -0,0 +1,7 @@
1
+ const eslintConfig = require('./eslint/config');
2
+ const prettierConfig = require('./prettier/config');
3
+
4
+ module.exports = {
5
+ eslintConfig,
6
+ prettierConfig,
7
+ };
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ printWidth: 120,
3
+ tabWidth: 4,
4
+ singleQuote: true,
5
+ semi: true,
6
+ trailingComma: 'es5',
7
+ arrowParens: 'always',
8
+ };