Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-config): New package for ESLint configurations #4

Merged
merged 3 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 1 addition & 84 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,87 +1,4 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/stylistic",
// "plugin:@typescript-eslint/strict-type-checked",
// "plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/recommended",
"plugin:import/typescript"
],
"env": {
"shared-node-browser": true,
"es2023": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true,
"ecmaVersion": 2023,
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "import"],
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"ecmaVersion": 2023,
"project": ["**/tsconfig.json"],
"projectFolderIgnoreList": ["**/node_modules/**"]
},
"node": true
}
},
"rules": {
"max-len": ["error", {"code": 120}],
"no-eval": ["error", {"allowIndirect": true}],
"no-floating-decimal": "error",
"space-infix-ops": "error",
"new-cap": ["error", {"capIsNewExceptionPattern": "Mixin$"}],
"brace-style": ["error", "stroustrup", {"allowSingleLine": true}],
"indent": "off",
"@typescript-eslint/indent": [
"error",
2,
{
"SwitchCase": 1,
"VariableDeclarator": 1,
"outerIIFEBody": 1,
"MemberExpression": 1,
"FunctionDeclaration": {"parameters": 1, "body": 1},
"FunctionExpression": {"parameters": 1, "body": 1},
"CallExpression": {"arguments": 1},
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"ignoreComments": false,
"ignoredNodes": [
"TemplateLiteral *",
"TSTypeParameterInstantiation",
"FunctionExpression > .params[decorators.length > 0]",
"FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
"ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
]
}
],
"operator-linebreak": ["error", "after", {"overrides": {"?": "before", ":": "before"}}],
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal", ["parent", "sibling", "index"], "object", "unknown", "type"],
"newlines-between": "always",
"warnOnUnassignedImports": true,
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"no-throw-literal": "off",
"require-jsdoc": "off",
"valid-jsdoc": "off"
}
"extends": "@alwatr/eslint-config"
}
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
enableTelemetry: false

preferInteractive: true
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"l": "yarn run lint",
"f": "yarn run format",
"rl": "yarn run pull && yarn run clean && yarn run build && yarn run release",
"upd": "yarn set version latest; yarn up '*' -i; yarn up '*' -R; yarn dlx @yarnpkg/sdks vscode; yarn dedupe",
"upd": "yarn set version latest; yarn up '*'; yarn up '*' -R; yarn dlx @yarnpkg/sdks vscode; yarn dedupe",
"lint": "eslint . --config .eslintrc.json --ext .ts",
"build": "lerna run build",
"format": "yarn run format:prettier && yarn run format:eslint",
Expand All @@ -32,6 +32,7 @@
"publish": "lerna publish from-package"
},
"devDependencies": {
"@alwatr/eslint-config": "workspace:^",
"@lerna-lite/changed": "^3.1.0",
"@lerna-lite/cli": "^3.1.0",
"@lerna-lite/diff": "^3.1.0",
Expand All @@ -42,7 +43,6 @@
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"prettier": "^3.1.1",
"typescript": "^5.3.3"
Expand Down
27 changes: 27 additions & 0 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ESLint Configurations

Alwatr ECMAScript Style Guide as a ESLint [shareable configurations](http://eslint.org/docs/developer-guide/shareable-configs.html).

## Installation

```bash
yarn add -D @alwatr/eslint-config \
eslint \
@typescript-eslint/parser \
@typescript-eslint/eslint-plugin \
eslint-plugin-import \
eslint-import-resolver-typescript
```

## Usage

Create a `.eslintrc.json` file in the root of your project:

```json
{
"extends": "@alwatr/eslint-config",
"rules": {
// Additional, per-project rules...
}
}
```
86 changes: 86 additions & 0 deletions packages/eslint-config/eslint-config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict',
'plugin:@typescript-eslint/stylistic',
// "plugin:@typescript-eslint/strict-type-checked",
// "plugin:@typescript-eslint/stylistic-type-checked",
'plugin:import/recommended',
'plugin:import/typescript',
],
env: {
'shared-node-browser': true,
es2023: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
ecmaVersion: 2023,
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'import'],
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
ecmaVersion: 2023,
project: ['**/tsconfig.json'],
projectFolderIgnoreList: ['**/node_modules/**'],
},
node: true,
},
},
rules: {
'max-len': ['error', {code: 120}],
'no-eval': ['error', {allowIndirect: true}],
'no-floating-decimal': 'error',
'space-infix-ops': 'error',
'new-cap': ['error', {capIsNewExceptionPattern: 'Mixin$'}],
'brace-style': ['error', 'stroustrup', {allowSingleLine: true}],
indent: 'off',
'@typescript-eslint/indent': [
'error',
2,
{
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
MemberExpression: 1,
FunctionDeclaration: {parameters: 1, body: 1},
FunctionExpression: {parameters: 1, body: 1},
CallExpression: {arguments: 1},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoreComments: false,
ignoredNodes: [
'TemplateLiteral *',
'TSTypeParameterInstantiation',
'FunctionExpression > .params[decorators.length > 0]',
'FunctionExpression > .params > :matches(Decorator, :not(:first-child))',
'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key',
],
},
],
'operator-linebreak': ['error', 'after', {overrides: {'?': 'before', ':': 'before'}}],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index'], 'object', 'unknown', 'type'],
'newlines-between': 'always',
warnOnUnassignedImports: true,
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-throw-literal': 'off',
'require-jsdoc': 'off',
'valid-jsdoc': 'off',
},
};
51 changes: 51 additions & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@alwatr/eslint-config",
"version": "1.0.0",
"description": "Build/bundle tools for ECMAScript, TypeScript, and JavaScript libraries. It's easy to use, doesn't require any setup, and adheres to best practices. It has no dependencies and uses esbuild for enhanced performance.",
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
"keywords": [
"build",
"bundle",
"esbuild",
"typescript",
"esm",
"alwatr"
],
"type": "commonjs",
"main": "./eslint-config.cjs",
"license": "MIT",
"files": [
"**/*.{d.ts.map,d.ts,js.map,js,html,md,cjs,mjs,cjs.map,mjs.map}"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/Alwatr/nanolib",
"directory": "packages/eslint-config"
},
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/eslint-config#readme",
"bugs": {
"url": "https://github.com/Alwatr/nanolib/issues"
},
"devDependencies": {
"@alwatr/tsconfig-base": "workspace:^",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"typescript": "^5.3.3"
},
"dependencies": {
"esbuild": "^0.19.10"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">6.0.0",
"@typescript-eslint/parser": ">6.0.0",
"eslint": ">8.0.0",
"eslint-import-resolver-typescript": ">3.0.0",
"eslint-plugin-import": ">2.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/flat-string/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

* build process ([83fc4e6](https://github.com/Alwatr/nanolib/commit/83fc4e609f86c25291e5f89016d6777bf197ffcb)) by @AliMD
- build process ([83fc4e6](https://github.com/Alwatr/nanolib/commit/83fc4e609f86c25291e5f89016d6777bf197ffcb)) by @AliMD

### Features

* **flat-string:** add new package for simplifies the complex C structures that are part of a combined JavaScript string ([ebfdcb3](https://github.com/Alwatr/nanolib/commit/ebfdcb368bc111e59d6b920f572d6365eef62144)) by @AliMD
- **flat-string:** add new package for simplifies the complex C structures that are part of a combined JavaScript string ([ebfdcb3](https://github.com/Alwatr/nanolib/commit/ebfdcb368bc111e59d6b920f572d6365eef62144)) by @AliMD
2 changes: 1 addition & 1 deletion packages/flat-string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you're frequently combining strings and then using that combined string somew
In simpler terms, `flatString` is a function that optimizes the way strings are stored in memory in JavaScript. When you concatenate strings, JavaScript internally creates a complex structure to save memory. However, when you need to use this string, for example, to write it to a file or send it over the network, this complex structure needs to be flattened, which can take time. By using `flatString`, you flatten the string right after concatenation, making the subsequent use of the string faster.

## Installation

```bash
yarn add @alwatr/flat-string
```
Expand Down
2 changes: 1 addition & 1 deletion packages/flat-string/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* myStr = flatString(myStr);
* ```
*/
export function flatString (str: string): string {
export function flatString(str: string): string {
// @ts-expect-error because it alters wrong compilation errors.
str | 0;
return str;
Expand Down
2 changes: 1 addition & 1 deletion packages/nano-build/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Features

* **nano-build:** new package for esbuild ([224a09e](https://github.com/Alwatr/nanolib/commit/224a09e9e20c0b8b1ff1de3c224ef84ee2be1f5b)) by @AliMD
- **nano-build:** new package for esbuild ([224a09e](https://github.com/Alwatr/nanolib/commit/224a09e9e20c0b8b1ff1de3c224ef84ee2be1f5b)) by @AliMD
2 changes: 1 addition & 1 deletion packages/nano-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Add the following scripts to your `package.json`:
"build": "nano-build",
"watch": "nano-build --watch",
"clean": "rm -rfv dist .tsbuildinfo"
},
}
}
```

Expand Down
2 changes: 1 addition & 1 deletion packages/nano-build/nano-build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const devMode = process.env.NODE_ENV !== 'production';
const alsoCjs = esbuildOptions.format === 'esm' && esbuildOptions.cjs;
delete esbuildOptions.cjs;

if(alsoCjs) {
if (alsoCjs) {
esbuildOptions.outExtension = {
...esbuildOptions.outExtension,
'.js': '.mjs',
Expand Down
4 changes: 2 additions & 2 deletions packages/tsconfig-base/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

* build process ([83fc4e6](https://github.com/Alwatr/nanolib/commit/83fc4e609f86c25291e5f89016d6777bf197ffcb)) by @AliMD
- build process ([83fc4e6](https://github.com/Alwatr/nanolib/commit/83fc4e609f86c25291e5f89016d6777bf197ffcb)) by @AliMD

### Features

* **tsconfig-base:** new package for TypeScript base config ([33bb94e](https://github.com/Alwatr/nanolib/commit/33bb94e38ab34634a26d51643f308cc651da695a)) by @AliMD
- **tsconfig-base:** new package for TypeScript base config ([33bb94e](https://github.com/Alwatr/nanolib/commit/33bb94e38ab34634a26d51643f308cc651da695a)) by @AliMD
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ __metadata:
languageName: node
linkType: hard

"@alwatr/eslint-config@workspace:^, @alwatr/eslint-config@workspace:packages/eslint-config":
version: 0.0.0-use.local
resolution: "@alwatr/eslint-config@workspace:packages/eslint-config"
dependencies:
"@alwatr/tsconfig-base": "workspace:^"
"@typescript-eslint/eslint-plugin": "npm:^6.15.0"
"@typescript-eslint/parser": "npm:^6.15.0"
esbuild: "npm:^0.19.10"
eslint: "npm:^8.56.0"
eslint-import-resolver-typescript: "npm:^3.6.1"
eslint-plugin-import: "npm:^2.29.1"
typescript: "npm:^5.3.3"
peerDependencies:
"@typescript-eslint/eslint-plugin": ">6.0.0"
"@typescript-eslint/parser": ">6.0.0"
eslint: ">8.0.0"
eslint-import-resolver-typescript: ">3.0.0"
eslint-plugin-import: ">2.0.0"
languageName: unknown
linkType: soft

"@alwatr/flat-string@workspace:packages/flat-string":
version: 0.0.0-use.local
resolution: "@alwatr/flat-string@workspace:packages/flat-string"
Expand Down Expand Up @@ -1233,6 +1254,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "alwatr-nanolib@workspace:."
dependencies:
"@alwatr/eslint-config": "workspace:^"
"@lerna-lite/changed": "npm:^3.1.0"
"@lerna-lite/cli": "npm:^3.1.0"
"@lerna-lite/diff": "npm:^3.1.0"
Expand All @@ -1243,7 +1265,6 @@ __metadata:
"@typescript-eslint/eslint-plugin": "npm:^6.15.0"
"@typescript-eslint/parser": "npm:^6.15.0"
eslint: "npm:^8.56.0"
eslint-import-resolver-typescript: "npm:^3.6.1"
eslint-plugin-import: "npm:^2.29.1"
prettier: "npm:^3.1.1"
typescript: "npm:^5.3.3"
Expand Down