@averay/codeformat 0.1.3 → 0.1.4
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/eslint.config.js +52 -18
- package/index.js +3 -3
- package/package.json +18 -13
package/eslint.config.js
CHANGED
|
@@ -1,30 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import js from '@eslint/js';
|
|
5
|
-
import typescript from '@typescript-eslint/eslint-plugin';
|
|
1
|
+
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
6
2
|
import typescriptParser from '@typescript-eslint/parser';
|
|
7
3
|
import prettierConfig from 'eslint-config-prettier';
|
|
4
|
+
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
|
|
5
|
+
import importPlugin from 'eslint-plugin-import';
|
|
6
|
+
import promisePlugin from 'eslint-plugin-promise';
|
|
7
|
+
import regexpPlugin from 'eslint-plugin-regexp';
|
|
8
|
+
import sonarjsPlugin from 'eslint-plugin-sonarjs';
|
|
9
|
+
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
import convertWarnsToErrors from './lib/convertWarnsToErrors.js';
|
|
12
|
+
import rulesetShared from './rulesets/ruleset-shared.js';
|
|
13
|
+
import rulesetTypescript from './rulesets/ruleset-typescript.js';
|
|
14
|
+
|
|
15
|
+
export const extensions = {
|
|
16
|
+
js: ['js', 'jsx', 'cjs', 'cjs', 'mjs', 'mjsx'],
|
|
17
|
+
ts: ['ts', 'tsx', 'cts', 'cts', 'mts', 'mtsx'],
|
|
18
|
+
};
|
|
10
19
|
|
|
11
20
|
export default [
|
|
21
|
+
// JavaScript & TypeScript
|
|
12
22
|
{
|
|
13
|
-
files: [
|
|
14
|
-
|
|
23
|
+
files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
|
|
24
|
+
plugins: {
|
|
25
|
+
'eslint-comments': eslintCommentsPlugin,
|
|
26
|
+
import: importPlugin,
|
|
27
|
+
promise: promisePlugin,
|
|
28
|
+
regexp: regexpPlugin,
|
|
29
|
+
sonarjs: sonarjsPlugin,
|
|
30
|
+
unicorn: unicornPlugin,
|
|
31
|
+
},
|
|
32
|
+
languageOptions: {
|
|
33
|
+
parserOptions: {
|
|
34
|
+
...importPlugin.configs.recommended.parserOptions,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
settings: {
|
|
38
|
+
'import/parsers': {
|
|
39
|
+
espree: extensions.js.map((extension) => `.${extension}`),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
rules: convertWarnsToErrors(rulesetShared),
|
|
15
43
|
},
|
|
44
|
+
|
|
45
|
+
// TypeScript
|
|
16
46
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
...typescript.configs.recommended.rules,
|
|
24
|
-
...typescript.configs['recommended-requiring-type-checking'].rules,
|
|
25
|
-
...typescript.configs.strict.rules,
|
|
26
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
47
|
+
files: [`**/*.{${extensions.ts.join(',')}}`],
|
|
48
|
+
languageOptions: {
|
|
49
|
+
parser: typescriptParser,
|
|
50
|
+
},
|
|
51
|
+
plugins: {
|
|
52
|
+
'@typescript-eslint': typescriptPlugin,
|
|
27
53
|
},
|
|
54
|
+
settings: {
|
|
55
|
+
...importPlugin.configs.typescript.settings,
|
|
56
|
+
'import/parsers': {
|
|
57
|
+
'@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
rules: convertWarnsToErrors(rulesetTypescript),
|
|
28
61
|
},
|
|
62
|
+
|
|
29
63
|
prettierConfig,
|
|
30
64
|
];
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import eslintConfig from './eslint.config.js';
|
|
1
|
+
import eslintConfig, { extensions } from './eslint.config.js';
|
|
2
2
|
|
|
3
|
-
export { default as eslintConfig } from './eslint.config.js';
|
|
3
|
+
export { default as eslintConfig, extensions } from './eslint.config.js';
|
|
4
4
|
|
|
5
5
|
export function makeEslintConfig(options) {
|
|
6
6
|
return [
|
|
7
7
|
...eslintConfig,
|
|
8
8
|
{
|
|
9
|
-
files: [
|
|
9
|
+
files: [`**/*.{${extensions.ts.join(',')}}`],
|
|
10
10
|
languageOptions: {
|
|
11
11
|
parserOptions: { project: options.tsconfigPath },
|
|
12
12
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@averay/codeformat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"author": "Adam Averay (https://adamaveray.com.au/)",
|
|
5
5
|
"homepage": "https://github.com/adamaveray/codeformat",
|
|
6
6
|
"repository": {
|
|
@@ -21,21 +21,26 @@
|
|
|
21
21
|
"index.js"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"format": "prettier
|
|
25
|
-
"
|
|
24
|
+
"format": "npm run format:prettier && npm run format:eslint",
|
|
25
|
+
"format:eslint": "eslint --fix .",
|
|
26
|
+
"format:prettier": "prettier --write .",
|
|
27
|
+
"lint": "npm run lint:prettier && npm run lint:eslint",
|
|
28
|
+
"lint:eslint": "eslint .",
|
|
29
|
+
"lint:prettier": "prettier --check .",
|
|
26
30
|
"prepare": "husky install"
|
|
27
31
|
},
|
|
28
|
-
"husky": {
|
|
29
|
-
"hooks": {
|
|
30
|
-
"pre-push": "npm run lint"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@eslint/eslintrc": "^2.0.
|
|
35
|
-
"@eslint/js": "^8.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^5.54.
|
|
37
|
-
"@typescript-eslint/parser": "^5.54.
|
|
38
|
-
"eslint-config-prettier": "^8.
|
|
33
|
+
"@eslint/eslintrc": "^2.0.1",
|
|
34
|
+
"@eslint/js": "^8.36.0",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
36
|
+
"@typescript-eslint/parser": "^5.54.1",
|
|
37
|
+
"eslint-config-prettier": "^8.7.0",
|
|
38
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
39
|
+
"eslint-plugin-import": "^2.27.5",
|
|
40
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
41
|
+
"eslint-plugin-regexp": "^1.12.0",
|
|
42
|
+
"eslint-plugin-sonarjs": "^0.18.0",
|
|
43
|
+
"eslint-plugin-unicorn": "^46.0.0",
|
|
39
44
|
"prettier": "^2.8.4"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {
|