eslint-plugin-raflint 1.0.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/README.md ADDED
@@ -0,0 +1 @@
1
+ salut
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // index.js
2
+ module.exports = {
3
+ rules: {
4
+ 'no-conditional-object-spread': require('./no-conditional-object-spread.js'),
5
+ },
6
+ };
package/jest.config.js ADDED
@@ -0,0 +1,4 @@
1
+ export default {
2
+ transform: {},
3
+ testTimeout: 60_000,
4
+ };
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ create(context) {
3
+ return {
4
+ SpreadElement(node) {
5
+ if (node.argument.type === 'ConditionalExpression' || node.argument.type === 'LogicalExpression') {
6
+ context.report({
7
+ node,
8
+ message: 'Conditional object spread is not allowed.',
9
+ });
10
+ }
11
+ },
12
+ };
13
+ },
14
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "eslint-plugin-raflint",
3
+ "version": "1.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "prepare": "husky install",
8
+ "jest": "SILENT=1 node --no-warnings --experimental-vm-modules ./node_modules/.bin/jest",
9
+ "test": "SILENT=1 mocha --timeout 15000 {lib,test}/**/*.test.js",
10
+ "cov": "c8 npm run test"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "ssh://git@gitea.raphaelpiccolo.com:10022/root/eslint-plugin-raflint.git"
18
+ },
19
+ "dependencies": {
20
+ "@babel/eslint-parser": "^7.22.5",
21
+ "c8": "^7.14.0",
22
+ "eslint": "^8.42.0",
23
+ "eslint-plugin-import": "^2.27.5",
24
+ "eslint-plugin-n": "^16.0.0",
25
+ "eslint-plugin-promise": "^6.1.1",
26
+ "eslint-plugin-sonarjs": "^0.19.0",
27
+ "eslint-plugin-unicorn": "^47.0.0",
28
+ "html-validate": "^8.0.0",
29
+ "husky": "^8.0.3",
30
+ "jest": "^29.5.0",
31
+ "lint-staged": "^13.2.2",
32
+ "mocha": "^10.2.0",
33
+ "prettier": "^2.8.8"
34
+ }
35
+ }
package/testeslint.js ADDED
@@ -0,0 +1,41 @@
1
+ const { RuleTester } = require('eslint');
2
+ const noConditionalObjectSpread = require('./no-conditional-object-spread.js');
3
+
4
+ const ruleTester = new RuleTester({
5
+ "parser": `${__dirname}/node_modules/@babel/eslint-parser`,
6
+ "parserOptions": {
7
+ "ecmaVersion": "latest",
8
+ "sourceType": "module",
9
+ "requireConfigFile": false
10
+ }
11
+ });
12
+
13
+ ruleTester.run('no-conditional-object-spread', noConditionalObjectSpread, {
14
+ valid: [
15
+ {
16
+ code: `
17
+ const condition = true;
18
+ const obj = {};
19
+ if (condition) obj.prop = value;
20
+ `,
21
+ }
22
+ ],
23
+ invalid: [
24
+ {
25
+ code: `
26
+ const obj = {
27
+ ...(condition ? { prop: 'value' } : {}),
28
+ };
29
+ `,
30
+ errors: [{ message: 'Conditional object spread is not allowed.' }],
31
+ },
32
+ {
33
+ code: `
34
+ const obj = {
35
+ ...(condition && { prop: 'value' }),
36
+ };
37
+ `,
38
+ errors: [{ message: 'Conditional object spread is not allowed.' }],
39
+ }
40
+ ]
41
+ });