-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into typescript-support
- Loading branch information
Showing
81 changed files
with
3,460 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,4 +82,4 @@ | |
"stylelint": { | ||
"extends": "./node_modules/@s-ui/lint/stylelint.config.js" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# CHANGELOG | ||
|
||
# 1.3.0 (2024-03-21) | ||
|
||
|
||
### Features | ||
|
||
* make public ([a43f568](https://github.com/SUI-Components/sui/commit/a43f5687fbe42ac970b18a1d1ecd918605a17234)) | ||
|
||
|
||
|
||
# 1.2.0 (2024-03-21) | ||
|
||
|
||
### Features | ||
|
||
* bump version ([1d832f4](https://github.com/SUI-Components/sui/commit/1d832f4b3efc651910a9b339286e5ac9693100bc)) | ||
|
||
|
||
|
||
# 1.0.0 (2024-03-21) | ||
|
||
|
||
### Features | ||
|
||
* add empty rule ([e2cef86](https://github.com/SUI-Components/sui/commit/e2cef862c94d6c0e8d8ea3f67df5e33a1dbaa6ae)) | ||
* add new dependency ([27c6e29](https://github.com/SUI-Components/sui/commit/27c6e29eed1b33f2fb5a06cff53413717a88a856)) | ||
* create few rules ([7e41dc7](https://github.com/SUI-Components/sui/commit/7e41dc7323cbe9dc782d3eb78a90fef651b72e19)) | ||
* fix more than one line in toJson ([3865416](https://github.com/SUI-Components/sui/commit/3865416ff0553fb36593a9cb138bd15c4cc29775)) | ||
* Improve rules to be more resilient ([369b096](https://github.com/SUI-Components/sui/commit/369b096faf6ff77791d41eac9b136ff68ff814b8)) | ||
* make warning ([c6ffa98](https://github.com/SUI-Components/sui/commit/c6ffa98cea6b262be5d203eaa91de5b82444aa46)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# eslint-plugin-sui | ||
|
||
Set of sui lint rules | ||
|
||
## Installation | ||
|
||
You'll first need to install [ESLint](https://eslint.org/): | ||
|
||
```sh | ||
npm i eslint --save-dev | ||
``` | ||
|
||
Next, install `eslint-plugin-sui`: | ||
|
||
```sh | ||
npm install eslint-plugin-sui --save-dev | ||
``` | ||
|
||
## Usage | ||
|
||
Add `sui` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: | ||
|
||
```json | ||
{ | ||
"plugins": [ | ||
"sui" | ||
] | ||
} | ||
``` | ||
|
||
|
||
Then configure the rules you want to use under the rules section. | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"sui/rule-name": 2 | ||
} | ||
} | ||
``` | ||
|
||
|
||
|
||
## Configurations | ||
|
||
<!-- begin auto-generated configs list --> | ||
TODO: Run eslint-doc-generator to generate the configs list (or delete this section if no configs are offered). | ||
<!-- end auto-generated configs list --> | ||
|
||
|
||
|
||
## Rules | ||
|
||
<!-- begin auto-generated rules list --> | ||
TODO: Run eslint-doc-generator to generate the rules list. | ||
<!-- end auto-generated rules list --> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Ensure that our classes are using the convetion of has a static create method as factory. (`factory-pattern`) | ||
|
||
Please describe the origin of the rule here. | ||
|
||
## Rule Details | ||
|
||
This rule aims to... | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
|
||
// fill me in | ||
|
||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
|
||
// fill me in | ||
|
||
``` | ||
|
||
### Options | ||
|
||
If there are any options, describe them here. Otherwise, delete this section. | ||
|
||
## When Not To Use It | ||
|
||
Give a short description of when it would be appropriate to turn off this rule. | ||
|
||
## Further Reading | ||
|
||
If there are other links that describe the issue this rule addresses, please include them here in a bulleted list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "eslint-plugin-sui", | ||
"version": "1.3.0", | ||
"access": "public", | ||
"description": "Set of sui lint rules", | ||
"keywords": [ | ||
"eslint", | ||
"eslintplugin", | ||
"eslint-plugin" | ||
], | ||
"author": "Sui", | ||
"main": "./src/index.js", | ||
"exports": "./src/index.js", | ||
"scripts": { | ||
"lint": "npx npm-run-all \"lint:*\"", | ||
"lint:eslint-docs": "npx npm-run-all \"update:eslint-docs -- --check\"", | ||
"lint:js": "npx eslint .", | ||
"test": "npx sui-test server", | ||
"update:eslint-docs": "npx eslint-doc-generator" | ||
}, | ||
"dependencies": { | ||
"requireindex": "1.2.0", | ||
"string-dedent": "3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@s-ui/test": "8", | ||
"eslint": "8.19.0", | ||
"eslint-doc-generator": "1.0.0", | ||
"eslint-plugin-eslint-plugin": "5.0.0", | ||
"eslint-plugin-node": "11.1.0" | ||
}, | ||
"engines": { | ||
"node": "^14.17.0 || ^16.0.0 || >= 18.0.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": ">=7" | ||
}, | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const FactoryPattern = require('./rules/factory-pattern.js') | ||
const SerializeDeserialize = require('./rules/serialize-deserialize.js') | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Plugin Definition | ||
// ------------------------------------------------------------------------------ | ||
|
||
// import all rules in lib/rules | ||
module.exports = { | ||
rules: { | ||
'factory-pattern': FactoryPattern, | ||
'serialize-deserialize': SerializeDeserialize | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @fileoverview Ensure that our classes are using the convetion of has a static create method as factory. | ||
* @author factory pattern | ||
*/ | ||
'use strict' | ||
|
||
const dedent = require('string-dedent') | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Rule Definition | ||
// ------------------------------------------------------------------------------ | ||
|
||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
meta: { | ||
type: 'warning', | ||
docs: { | ||
description: 'ensure to define at least one factory function', | ||
recommended: true, | ||
url: 'https://github.mpi-internal.com/scmspain/es-td-agreements/blob/master/30-Frontend/00-agreements' | ||
}, | ||
fixable: null, | ||
schema: [], | ||
messages: { | ||
notFoundFactoryFunction: dedent` | ||
You have to define at least one static function that return an instance of your class. | ||
Avoid to use the 'new' keyword directly in your code. | ||
Use always a factory function | ||
` | ||
} | ||
}, | ||
create: function (context) { | ||
// variables should be defined here | ||
|
||
// ---------------------------------------------------------------------- | ||
// Helpers | ||
// ---------------------------------------------------------------------- | ||
|
||
// any helper functions should go here or else delete this section | ||
|
||
// ---------------------------------------------------------------------- | ||
// Public | ||
// ---------------------------------------------------------------------- | ||
|
||
return { | ||
ClassDeclaration(node) { | ||
const hasStaticFactoryMethod = Boolean( | ||
node.body?.body?.find(methodDefinition => { | ||
return ( | ||
methodDefinition.static && | ||
methodDefinition.value?.body?.body?.find?.(body => body.type === 'ReturnStatement')?.argument?.callee?.name === node?.id?.name // eslint-disable-line | ||
) | ||
}) | ||
) | ||
|
||
if (!hasStaticFactoryMethod) { | ||
context.report({ | ||
node: node?.id ?? node.superClass ?? node, | ||
messageId: 'notFoundFactoryFunction' | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @fileoverview Ensure that our coda doesnt have require (CJS) styles | ||
* @author factory pattern | ||
*/ | ||
'use strict' | ||
|
||
const dedent = require('string-dedent') | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Rule Definition | ||
// ------------------------------------------------------------------------------ | ||
|
||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'ensure to use only ESM (import) style', | ||
recommended: true, | ||
url: 'https://github.mpi-internal.com/scmspain/es-td-agreements/blob/master/30-Frontend/00-agreements' | ||
}, | ||
fixable: null, | ||
schema: [], | ||
messages: { | ||
badFileName: dedent``, | ||
badClassName: dedent`` | ||
} | ||
}, | ||
create: function (context) { | ||
// variables should be defined here | ||
|
||
// ---------------------------------------------------------------------- | ||
// Helpers | ||
// ---------------------------------------------------------------------- | ||
|
||
// any helper functions should go here or else delete this section | ||
|
||
// ---------------------------------------------------------------------- | ||
// Public | ||
// ---------------------------------------------------------------------- | ||
|
||
return { | ||
ClassDeclaration(node) {} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/eslint-plugin-sui/src/rules/function-named-parameters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @fileoverview Ensure that our function are using always named parameters | ||
* @author factory pattern | ||
*/ | ||
'use strict' | ||
|
||
const dedent = require('string-dedent') | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Rule Definition | ||
// ------------------------------------------------------------------------------ | ||
|
||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'ensure to use named parameters', | ||
recommended: true, | ||
url: 'https://github.mpi-internal.com/scmspain/es-td-agreements/blob/master/30-Frontend/00-agreements' | ||
}, | ||
fixable: null, | ||
schema: [], | ||
messages: { | ||
badFileName: dedent``, | ||
badClassName: dedent`` | ||
} | ||
}, | ||
create: function (context) { | ||
// variables should be defined here | ||
|
||
// ---------------------------------------------------------------------- | ||
// Helpers | ||
// ---------------------------------------------------------------------- | ||
|
||
// any helper functions should go here or else delete this section | ||
|
||
// ---------------------------------------------------------------------- | ||
// Public | ||
// ---------------------------------------------------------------------- | ||
|
||
return { | ||
ClassDeclaration(node) {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @fileoverview Ensure that our classes are using the naming convention for UseCases, Services and Repositories | ||
* @author factory pattern | ||
*/ | ||
'use strict' | ||
|
||
const dedent = require('string-dedent') | ||
|
||
// ------------------------------------------------------------------------------ | ||
// Rule Definition | ||
// ------------------------------------------------------------------------------ | ||
|
||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
meta: { | ||
type: 'problem', | ||
docs: { | ||
description: 'ensure to use a proper naming convention', | ||
recommended: true, | ||
url: 'https://github.mpi-internal.com/scmspain/es-td-agreements/blob/master/30-Frontend/00-agreements' | ||
}, | ||
fixable: null, | ||
schema: [], | ||
messages: { | ||
badFileName: dedent``, | ||
badClassName: dedent`` | ||
} | ||
}, | ||
create: function (context) { | ||
// variables should be defined here | ||
|
||
// ---------------------------------------------------------------------- | ||
// Helpers | ||
// ---------------------------------------------------------------------- | ||
|
||
// any helper functions should go here or else delete this section | ||
|
||
// ---------------------------------------------------------------------- | ||
// Public | ||
// ---------------------------------------------------------------------- | ||
|
||
return { | ||
ClassDeclaration(node) {} | ||
} | ||
} | ||
} |
Oops, something went wrong.