Skip to content

Commit 3e028d5

Browse files
@jotadevelopersergiohgz
authored andcommitted
feat(eslint-plugin-verdaccio): import eslint-plugin-verdaccio package
- chore: initial commit - test: add more valid options - docs: add docs - fix typo - feat: add no-style attribute rule - 0.0.2 - feat: add rule jsx-no-classname-object - 0.0.3 - fix: update id rules - 0.0.4 - fix: update error message - 0.0.5
1 parent 98f0de7 commit 3e028d5

File tree

17 files changed

+2416
-0
lines changed

17 files changed

+2416
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
9+
# 2 space indentation
10+
[{.,}*.{js,jsx,yml,yaml}]
11+
indent_style = space
12+
indent_size = 2
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"node": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": 6,
8+
"ecmaFeatures": {
9+
"jsx": true
10+
}
11+
},
12+
"rules": {
13+
"comma-dangle": [2, "never"],
14+
"computed-property-spacing": [2, "never"],
15+
"no-cond-assign": 2,
16+
"no-console": 2,
17+
"no-constant-condition": 2,
18+
"no-control-regex": 2,
19+
"no-debugger": 2,
20+
"no-dupe-keys": 2,
21+
"no-empty": 2,
22+
"no-empty-character-class": 2,
23+
"no-ex-assign": 2,
24+
"no-extra-boolean-cast": 2,
25+
"no-extra-parens": 0,
26+
"no-extra-semi": 2,
27+
"no-func-assign": 2,
28+
"no-inner-declarations": 2,
29+
"no-invalid-regexp": 2,
30+
"no-irregular-whitespace": 2,
31+
"no-negated-in-lhs": 2,
32+
"no-obj-calls": 2,
33+
"no-regex-spaces": 2,
34+
"no-reserved-keys": 0,
35+
"no-sparse-arrays": 2,
36+
"no-unreachable": 2,
37+
"use-isnan": 2,
38+
"valid-jsdoc": 0,
39+
"valid-typeof": 2,
40+
// Best Practices
41+
"block-scoped-var": 2,
42+
"complexity": 0,
43+
"consistent-return": 2,
44+
"curly": 2,
45+
"default-case": 2,
46+
"dot-notation": 2,
47+
"eqeqeq": 2,
48+
"guard-for-in": 2,
49+
"no-alert": 2,
50+
"no-caller": 2,
51+
"no-confusing-arrow": 2,
52+
"no-div-regex": 2,
53+
"no-else-return": 2,
54+
"no-eq-null": 2,
55+
"no-eval": 2,
56+
"no-extend-native": 2,
57+
"no-extra-bind": 2,
58+
"no-fallthrough": 2,
59+
"no-floating-decimal": 2,
60+
"no-implied-eval": 2,
61+
"no-iterator": 2,
62+
"no-labels": 2,
63+
"no-lone-blocks": 2,
64+
"no-loop-func": 2,
65+
"no-multi-spaces": 2,
66+
"no-multi-str": 2,
67+
"no-native-reassign": 2,
68+
"no-new": 2,
69+
"no-new-func": 2,
70+
"no-new-wrappers": 2,
71+
"no-octal": 2,
72+
"no-octal-escape": 2,
73+
"no-process-env": 2,
74+
"no-proto": 2,
75+
"no-redeclare": 2,
76+
"no-return-assign": 2,
77+
"no-script-url": 2,
78+
"no-self-compare": 2,
79+
"no-sequences": 2,
80+
"no-unused-expressions": 2,
81+
"no-void": 0,
82+
"no-warning-comments": 2,
83+
"no-with": 2,
84+
"prefer-arrow-callback": 2,
85+
"radix": 2,
86+
"vars-on-top": 0,
87+
"wrap-iife": 2,
88+
"yoda": 2,
89+
// Strict Mode
90+
"strict": [2, "global"],
91+
// Variables
92+
"prefer-const": 2,
93+
"no-catch-shadow": 2,
94+
"no-const-assign": 2,
95+
"no-delete-var": 2,
96+
"no-label-var": 2,
97+
"no-shadow": 2,
98+
"no-shadow-restricted-names": 2,
99+
"no-undef": 2,
100+
"no-undef-init": 2,
101+
"no-undefined": 2,
102+
"no-unused-vars": 2,
103+
"no-use-before-define": 2,
104+
"no-var": 2,
105+
// Stylistic Issues
106+
"indent": [2, 2, {
107+
"SwitchCase": 1
108+
}],
109+
"arrow-body-style": [2, "as-needed"],
110+
"arrow-parens": [2, "as-needed"],
111+
"arrow-spacing": 2,
112+
"brace-style": 2,
113+
"camelcase": 0,
114+
"comma-spacing": 2,
115+
"comma-style": 2,
116+
"consistent-this": 0,
117+
"eol-last": 2,
118+
"func-names": 0,
119+
"func-style": 0,
120+
"key-spacing": [2, {
121+
"beforeColon": false,
122+
"afterColon": true
123+
}],
124+
"max-nested-callbacks": 0,
125+
"new-cap": 2,
126+
"new-parens": 2,
127+
"no-array-constructor": 2,
128+
"no-inline-comments": 0,
129+
"no-lonely-if": 2,
130+
"no-mixed-spaces-and-tabs": 2,
131+
"no-nested-ternary": 2,
132+
"no-new-object": 2,
133+
"semi-spacing": [2, {
134+
"before": false,
135+
"after": true
136+
}],
137+
"no-spaced-func": 2,
138+
"no-ternary": 0,
139+
"no-trailing-spaces": 2,
140+
"no-multiple-empty-lines": 2,
141+
"no-underscore-dangle": 0,
142+
"one-var": 0,
143+
"operator-assignment": [2, "always"],
144+
"padded-blocks": [2, { "blocks": "never", "classes": "never", "switches": "never" }],
145+
"quotes": [2, "single"],
146+
"quote-props": [2, "as-needed"],
147+
"semi": [2, "always"],
148+
"sort-vars": [2, {"ignoreCase": true}],
149+
"keyword-spacing": 2,
150+
"space-before-blocks": 2,
151+
"object-curly-spacing": [2, "never"],
152+
"array-bracket-spacing": [2, "never"],
153+
"space-in-parens": 2,
154+
"space-infix-ops": 2,
155+
"space-unary-ops": 2,
156+
"spaced-comment": 2,
157+
"wrap-regex": 0,
158+
// Legacy
159+
"max-depth": 0,
160+
"max-len": [2, 120, {
161+
"ignoreStrings": true,
162+
"ignoreTemplateLiterals": true,
163+
"ignoreComments": true,
164+
}],
165+
"max-params": 0,
166+
"max-statements": 0,
167+
"no-plusplus": 0,
168+
"no-prototype-builtins": 2,
169+
"prefer-template": 2,
170+
"template-curly-spacing": [2, "never"],
171+
}
172+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
*.log
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.eslint
2+
node_modules
3+
docs
4+
tests/
5+
*.lock
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# eslint-plugin-verdaccio
2+
3+
verdaccio code guide lines
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-verdaccio`:
14+
15+
```
16+
$ npm install eslint-plugin-verdaccio --save-dev
17+
```
18+
19+
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-verdaccio` globally.
20+
21+
## Usage
22+
23+
Add `verdaccio` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
24+
25+
```json
26+
{
27+
"plugins": [
28+
"verdaccio"
29+
]
30+
}
31+
```
32+
33+
34+
Then configure the rules you want to use under the rules section.
35+
36+
```json
37+
{
38+
"rules": {
39+
"verdaccio/jsx-spread": "error",
40+
"verdaccio/jsx-no-style": "error",
41+
"verdaccio/jsx-no-classname-object": "error"
42+
}
43+
}
44+
```
45+
46+
## Supported Rules
47+
48+
* [verdaccio/jsx-spread](docs/rules/jsx-spread.md): Enforce don"t use of spread operators with JSX components.
49+
* [verdaccio/jsx-no-style](docs/rules/jsx-no-style.md): Enforce don"t use of style attribute with JSX components.
50+
* [verdaccio/jsx-no-classname-object](docs/rules/jsx-no-classname-object.md): Enforce don"t use of nested objects on className attribute with JSX components.
51+
52+
53+
54+
55+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# check the usage of nested objects as classnames (jsx-no-classname-object)
2+
3+
Please describe the origin of the rule here.
4+
5+
6+
## Rule Details
7+
8+
This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations:
9+
10+
* `always`: The className attribute does not allow object expressions
11+
* `never` : The className attribute does allow object expressions
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```js
16+
'<div className="{}"/>',
17+
'<div className={"test"}/>',
18+
'<div className="test"/>',
19+
'<div className={this.getClassName()}/>'
20+
```
21+
22+
Examples of **correct** code for this rule:
23+
24+
```js
25+
26+
'<div className={{fontSize: \'12px\'}}/>'
27+
28+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# disallow style on jsx components (jsx-no-style)
2+
3+
Please describe the origin of the rule here.
4+
5+
6+
## Rule Details
7+
8+
This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations:
9+
10+
* `always`: The style attribute is invalid as JSX attribute.
11+
* `never` : The style attribute is allowed as JSX attribute.
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```js
16+
17+
<span key={String(index)} href={suggestion.link} style={{ fontWeight: fontWeight.semiBold }}>
18+
{part.text}
19+
</span>
20+
21+
<InputAdornment position="start" style={{ color: colors.white }}>
22+
<IconSearch />
23+
</InputAdornment>
24+
25+
```
26+
27+
Examples of **correct** code for this rule:
28+
29+
```js
30+
31+
<span key={String(index)} href={suggestion.link} className="bar">
32+
{part.text}
33+
</span>
34+
35+
<InputAdornment position="start" className="foo">
36+
<IconSearch />
37+
</InputAdornment>
38+
39+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# spread over jsx (jsx-spread)
2+
3+
Please describe the origin of the rule here.
4+
5+
6+
## Rule Details
7+
8+
This rule checks whether the first property of all JSX elements is correctly placed. There are the possible configurations:
9+
10+
* `always`: The spread operator is invalid as JSX attribute.
11+
* `never` : The spread operator is allowed as JSX attribute.
12+
13+
Examples of **incorrect** code for this rule:
14+
15+
```js
16+
17+
<div {...props}>
18+
19+
```
20+
21+
Examples of **correct** code for this rule:
22+
23+
```js
24+
25+
<div foo="1" bar="2"/>
26+
27+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
module.exports = {
4+
configs: {
5+
recommended: {
6+
plugins: ['verdaccio'],
7+
rules: {
8+
'verdaccio/jsx-spread': 'error',
9+
'verdaccio/jsx-no-style': 'error',
10+
'verdaccio/jsx-no-classname-object': 'error'
11+
}
12+
}
13+
},
14+
rules: {
15+
'jsx-spread': require('./rules/jsx-spread'),
16+
'jsx-no-style': require('./rules/jsx-no-style'),
17+
'jsx-no-classname-object': require('./rules/jsx-no-classname-object')
18+
},
19+
rulesConfig: {
20+
'jsx-spread': 2,
21+
'jsx-no-style': 2,
22+
'jsx-no-classname-object': 2
23+
}
24+
};

0 commit comments

Comments
 (0)