@oncehub/eslint-config 2.1.1 → 3.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -13
  3. package/index.js +46 -45
  4. package/package.json +21 -10
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Oncehub LTD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,26 +1,59 @@
1
- Introduction
2
- =
3
- ESLint configuration for micro-services built using Node.js and TypeScript.
1
+ # eslint-config-oncehub
2
+
3
+ [![Build status](https://github.com/scheduleonce/eslint-config-oncehub/actions/workflows/node.js.yml/badge.svg)](https://github.com/scheduleonce/eslint-config-oncehub/actions) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
4
+
5
+ > ESLint configuration for services built with Node.js and TypeScript.
4
6
 
5
7
  The configuration extends `@typescript-eslint/recommended`, `eslint-plugin-sonarjs`, `prettier` ESLint configurations.
6
8
 
9
+ It is compatible with ESlint >= v9 configuration format (flat config).
10
+
7
11
  ## Installation
8
- Using **NPM**
9
- ```sh
10
- npm i --save-dev @oncehub/eslint-config
11
- ```
12
12
 
13
- Using **Yarn**
13
+ To install this module, run the following command:
14
+
14
15
  ```sh
15
- yarn add --dev @oncehub/eslint-config
16
+ $ npm install --save-dev @oncehub/eslint-config
16
17
  ```
17
18
 
19
+ Note that it requires ESlint v9 and above.
20
+
18
21
  ## Usage
22
+
19
23
  In your `.eslintrc` file, put `@oncehub/eslint-config` under `extends` array as shown below.
24
+
20
25
  ```js
21
26
  module.exports = {
22
- 'extends': [
23
- '@oncehub/eslint-config'
24
- ]
27
+ extends: ["@oncehub/eslint-config"],
25
28
  };
26
- ```
29
+ ```
30
+
31
+ ## Development
32
+
33
+ ### Tests
34
+
35
+ Run tests via `npm test`.
36
+ The tests are comparing the eslint configuration against a previously saved snapshot of the rules so if you are adding or removing any rule, make sure to update the tests.
37
+
38
+ As a byproduct, the tests are also checking that the configuration is valid and all is okay with it.
39
+ You can also further debug the config via:
40
+
41
+ ```sh
42
+ $ npx eslint --debug -c index.js index.js
43
+ ```
44
+
45
+ To generate a new rules snapshot file:
46
+
47
+ ```sh
48
+ $ npx eslint --print-config index.js -c index.js > output.json
49
+ ```
50
+
51
+ Copy the rules from the output file into `test/rules-snapshot.js`
52
+
53
+ ### Deployment
54
+
55
+ Package is automatically published to npm when [creating a new release](.github/workflows/npm-publish.yml) on Github. Check out the release section in the repo. Read more about releases [here](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
56
+
57
+ ## License
58
+
59
+ This module is licensed under the MIT License. See the LICENSE file for details.
package/index.js CHANGED
@@ -1,47 +1,48 @@
1
- module.exports = {
2
- 'env': {
3
- 'es6': true,
4
- 'node': true,
1
+ import js from "@eslint/js";
2
+ import prettierConfig from "eslint-config-prettier";
3
+ import * as typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
4
+ import sonarjs from "eslint-plugin-sonarjs";
5
+
6
+ export default [
7
+ js.configs.recommended,
8
+ sonarjs.configs.recommended,
9
+ prettierConfig,
10
+ {
11
+ files: ["**/*.{js,ts,jsx,tsx}"],
12
+ languageOptions: {
13
+ globals: {
14
+ Atomics: "readonly",
15
+ SharedArrayBuffer: "readonly",
16
+ es6: true,
17
+ node: true,
18
+ },
19
+ parser: typescriptEslintPlugin.parser,
20
+ parserOptions: {
21
+ ecmaVersion: 2018,
22
+ sourceType: "module",
23
+ },
24
+ },
25
+ plugins: {
26
+ "@typescript-eslint": typescriptEslintPlugin,
27
+ // sonarjs,
28
+ },
29
+ rules: {
30
+ "@typescript-eslint/no-use-before-define": "off",
31
+ "@typescript-eslint/no-inferrable-types": "off",
32
+ "@typescript-eslint/no-unused-vars": "error",
33
+ "@typescript-eslint/interface-name-prefix": "off",
34
+ "@typescript-eslint/consistent-type-assertions": [
35
+ "error",
36
+ { assertionStyle: "angle-bracket" },
37
+ ],
38
+ "@typescript-eslint/no-explicit-any": "off",
39
+ "@typescript-eslint/explicit-function-return-type": "off",
40
+ },
5
41
  },
6
- 'extends': [
7
- 'plugin:@typescript-eslint/recommended',
8
- 'plugin:sonarjs/recommended',
9
- 'prettier'
10
- ],
11
- 'globals': {
12
- 'Atomics': 'readonly',
13
- 'SharedArrayBuffer': 'readonly',
42
+ {
43
+ files: ["**/*(specs|tests)/**", "**/*.spec.ts"],
44
+ rules: {
45
+ "@typescript-eslint/no-empty-function": "off",
46
+ },
14
47
  },
15
- 'parser': '@typescript-eslint/parser',
16
- 'parserOptions': {
17
- 'ecmaVersion': 2018,
18
- 'sourceType': 'module',
19
- },
20
- 'plugins': [
21
- '@typescript-eslint',
22
- 'sonarjs'
23
- ],
24
- 'overrides': [
25
- {
26
- 'files': ['**/*(specs|tests)/**', '**/*.spec.ts'],
27
- 'rules': {
28
- '@typescript-eslint/no-empty-function': 'off',
29
- 'sonarjs/no-identical-functions': 'off',
30
- 'sonarjs/no-duplicate-string': 'off'
31
- }
32
- }
33
- ],
34
- 'rules': {
35
- '@typescript-eslint/no-use-before-define': 'off',
36
- '@typescript-eslint/no-inferrable-types': 'off',
37
- '@typescript-eslint/explicit-function-return-type': 'error',
38
- '@typescript-eslint/no-unused-vars': 'error',
39
- '@typescript-eslint/no-explicit-any': 'error',
40
- '@typescript-eslint/interface-name-prefix': 'off',
41
- '@typescript-eslint/consistent-type-assertions': ['error', {
42
- assertionStyle: 'angle-bracket'
43
- }],
44
- '@typescript-eslint/no-explicit-any': 'off',
45
- '@typescript-eslint/explicit-function-return-type': 'off'
46
- }
47
- };
48
+ ];
package/package.json CHANGED
@@ -1,20 +1,26 @@
1
1
  {
2
2
  "name": "@oncehub/eslint-config",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
4
4
  "description": "ESLint configuration for micro-services built using Node.js and TypeScript",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "node test"
8
8
  },
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "type": "module",
9
13
  "author": "Rajat Saxena <rajat.saxena@oncehub.com>",
10
- "license": "ISC",
14
+ "license": "MIT",
11
15
  "dependencies": {
12
- "@typescript-eslint/eslint-plugin": "^5.6.0",
13
- "@typescript-eslint/parser": "^5.6.0",
14
- "eslint": "^8.4.1",
15
- "eslint-config-prettier": "^8.3.0",
16
- "eslint-plugin-sonarjs": "^0.11.0",
17
- "typescript": "^4.1.3"
16
+ "@eslint/js": "^9.14.0",
17
+ "@types/eslint__js": "^8.42.3",
18
+ "eslint-config-prettier": "^9.1.0",
19
+ "eslint-plugin-sonarjs": "^2.0.4",
20
+ "typescript-eslint": "^8.13.0"
21
+ },
22
+ "peerDependencies": {
23
+ "eslint": ">= 9"
18
24
  },
19
25
  "repository": {
20
26
  "type": "git",
@@ -23,5 +29,10 @@
23
29
  "bugs": {
24
30
  "url": "https://github.com/scheduleonce/eslint-config-oncehub/issues"
25
31
  },
26
- "homepage": "https://github.com/scheduleonce/eslint-config-oncehub#readme"
32
+ "homepage": "https://github.com/scheduleonce/eslint-config-oncehub#readme",
33
+ "files": [
34
+ "index.js",
35
+ "README.md",
36
+ "LICENSE"
37
+ ]
27
38
  }