@asd14/eslint-config 10.3.0 → 11.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 (61) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +24 -177
  3. package/dist/types/eslint.config.d.ts +172 -0
  4. package/dist/types/src/configs/dev-files.d.ts +14 -0
  5. package/dist/types/src/configs/node-jest.d.ts +17 -0
  6. package/dist/types/src/configs/node.d.ts +248 -0
  7. package/dist/types/src/configs/react-jest.d.ts +20 -0
  8. package/dist/types/src/configs/react.d.ts +1519 -0
  9. package/dist/types/src/configs/ts-node.d.ts +290 -0
  10. package/dist/types/src/index.d.ts +6 -0
  11. package/dist/types/src/rules/base.d.ts +16 -0
  12. package/dist/types/src/rules/import-dev.d.ts +9 -0
  13. package/dist/types/src/rules/import.d.ts +44 -0
  14. package/dist/types/src/rules/jsdoc.d.ts +40 -0
  15. package/dist/types/src/rules/nx-dev.d.ts +13 -0
  16. package/dist/types/src/rules/nx.d.ts +45 -0
  17. package/dist/types/src/rules/react.d.ts +120 -0
  18. package/dist/types/src/rules/rtl.d.ts +13 -0
  19. package/dist/types/src/rules/typescript.d.ts +53 -0
  20. package/dist/types/src/rules/unicorn.d.ts +42 -0
  21. package/dist/types/src/utils/find-up-sync.d.ts +34 -0
  22. package/dist/types/tsconfig.tsbuildinfo +1 -0
  23. package/package.json +51 -67
  24. package/src/configs/dev-files.js +17 -0
  25. package/src/configs/node-jest.js +29 -0
  26. package/src/configs/node.js +68 -0
  27. package/src/configs/react-jest.js +16 -0
  28. package/src/configs/react.js +89 -0
  29. package/src/configs/ts-node.js +23 -0
  30. package/src/index.js +6 -0
  31. package/src/rules/base.js +24 -0
  32. package/src/rules/import-dev.js +31 -0
  33. package/src/rules/import.js +55 -0
  34. package/src/rules/jsdoc.js +49 -0
  35. package/src/rules/nx-dev.js +23 -0
  36. package/src/rules/nx.js +81 -0
  37. package/{rules → src/rules}/react.js +41 -27
  38. package/src/rules/rtl.js +6 -0
  39. package/src/rules/typescript.js +88 -0
  40. package/{rules → src/rules}/unicorn.js +19 -41
  41. package/src/utils/find-up-sync.js +56 -0
  42. package/rules/best-practices.js +0 -11
  43. package/rules/comments.js +0 -46
  44. package/rules/errors.js +0 -112
  45. package/rules/es6.js +0 -48
  46. package/rules/html.js +0 -59
  47. package/rules/import-ts.js +0 -41
  48. package/rules/import.js +0 -101
  49. package/rules/jsdoc-ts.js +0 -8
  50. package/rules/jsdoc.js +0 -103
  51. package/rules/json.js +0 -9
  52. package/rules/node.js +0 -56
  53. package/rules/prettier.js +0 -16
  54. package/rules/promise.js +0 -68
  55. package/rules/style.js +0 -252
  56. package/rules/variables.js +0 -70
  57. package/targets/node-esm.js +0 -25
  58. package/targets/node-ts.js +0 -36
  59. package/targets/node.js +0 -36
  60. package/targets/react-ts.js +0 -94
  61. package/targets/react.js +0 -90
@@ -0,0 +1,56 @@
1
+ import fs from "node:fs"
2
+ import path from "node:path"
3
+
4
+ /**
5
+ * @typedef {Object} FindUpSyncOptions
6
+ *
7
+ * @property {string} [cwd] - The current working directory to start from.
8
+ */
9
+
10
+ /**
11
+ * @callback FindUpSyncFn
12
+ *
13
+ * @param {string} fileName - The name of the file to find.
14
+ * @param {FindUpSyncOptions} [options] - Options for the function.
15
+ * @returns {string} The absolute path to the file.
16
+ */
17
+
18
+ /**
19
+ * Find a file up the directory tree synchronously.
20
+ *
21
+ * @type {FindUpSyncFn}
22
+ *
23
+ * @throws {Error} If the starting folder does not exist.
24
+ *
25
+ * @throws {Error} If the file does not exist up the tree.
26
+ *
27
+ * @example
28
+ * const filePath = findUpSync("lerna.json");
29
+ * //=> "/Users/johndoe/Projects/WootWoot/lerna.json"
30
+ *
31
+ */
32
+ const findUpSync = (fileName, options = {}) => {
33
+ let { cwd } = options
34
+ cwd = path.resolve(cwd ?? process.cwd())
35
+
36
+ if (!fs.statSync(cwd).isDirectory()) {
37
+ throw new Error(`Path "${cwd}" does not exist or is not a directory`)
38
+ }
39
+
40
+ let { root } = path.parse(cwd)
41
+
42
+ while (cwd !== root) {
43
+ const file_path = path.join(cwd, fileName)
44
+
45
+ if (fs.existsSync(file_path)) {
46
+ return file_path
47
+ }
48
+
49
+ cwd = path.dirname(cwd)
50
+ root = path.parse(cwd).root
51
+ }
52
+
53
+ throw new Error(`File "${fileName}" does not exist up the tree`)
54
+ }
55
+
56
+ export { findUpSync }
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- // Encourages use of dot notation whenever possible
4
- "dot-notation": [
5
- "error",
6
- {
7
- allowKeywords: true,
8
- },
9
- ],
10
- },
11
- }
package/rules/comments.js DELETED
@@ -1,46 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- /*
4
- * Enforce a consistent style of comments across your codebase,
5
- * specifically by either requiring or disallowing a capitalized
6
- * letter as the first word character in a comment. This rule will not
7
- * issue warnings when non-cased letters are used.
8
- */
9
- "capitalized-comments": "off",
10
-
11
- /*
12
- * Enforces consistent position of line comments. Block comments are
13
- * not affected by this rule. By default, this rule ignores comments
14
- * starting with the following words: eslint, jshint, jslint,
15
- * istanbul, global, exported, jscs, falls through.
16
- */
17
- "line-comment-position": [
18
- "error",
19
- {
20
- position: "above",
21
- },
22
- ],
23
-
24
- // Disallow usage of configurable warning terms in comments: e.g. todo
25
- "no-warning-comments": [
26
- 0,
27
- {
28
- location: "start",
29
- terms: ["todo", "fixme", "xxx"],
30
- },
31
- ],
32
-
33
- /*
34
- * Enforce consistency of spacing after the start of a comment // or
35
- * /*. It also provides several exceptions for various documentation
36
- * styles.
37
- */
38
- "spaced-comment": ["error", "always"],
39
-
40
- /*
41
- * This rule aims to enforce a particular style for
42
- * multiline comments.
43
- */
44
- "multiline-comment-style": "off",
45
- },
46
- }
package/rules/errors.js DELETED
@@ -1,112 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- /*
4
- * A for loop with a stop condition that can never be reached, such as
5
- * one with a counter that moves in the wrong direction, will run
6
- * infinitely. While there are occasions when an infinite loop is
7
- * intended, the convention is to construct such loops as while loops.
8
- * More typically, an infinite for loop is a bug.
9
- */
10
- "for-direction": "error",
11
-
12
- // Disallow assignment in conditional expressions
13
- "no-cond-assign": ["error", "always"],
14
-
15
- // Disallow use of console
16
- "no-console": 1,
17
-
18
- // Disallow use of constant expressions in conditions
19
- "no-constant-condition": 1,
20
-
21
- // Disallow control characters in regular expressions
22
- "no-control-regex": "error",
23
-
24
- // Disallow use of debugger
25
- "no-debugger": 1,
26
-
27
- // Disallow duplicate arguments in functions
28
- "no-dupe-args": "error",
29
-
30
- // Disallow duplicate keys when creating object literals
31
- "no-dupe-keys": "error",
32
-
33
- // Disallow a duplicate case label.
34
- "no-duplicate-case": "error",
35
-
36
- // Disallow empty statements
37
- "no-empty": "error",
38
-
39
- // Disallow the use of empty character classes in regular expressions
40
- "no-empty-character-class": "error",
41
-
42
- // Disallow assigning to the exception in a catch block
43
- "no-ex-assign": "error",
44
-
45
- // Disallow double-negation boolean casts in a boolean context
46
- "no-extra-boolean-cast": 0,
47
-
48
- // Disallow overwriting functions written as function declarations
49
- "no-func-assign": "error",
50
-
51
- // Disallow function or variable declarations in nested blocks
52
- "no-inner-declarations": "error",
53
-
54
- /*
55
- * Disallow invalid regular expression strings in the RegExp
56
- * Constructor
57
- */
58
- "no-invalid-regexp": "error",
59
-
60
- // Disallow irregular whitespace outside of strings and comments
61
- "no-irregular-whitespace": "error",
62
-
63
- // Disallow negation of the left operand of an in expression
64
- "no-negated-in-lhs": "error",
65
-
66
- /*
67
- * Disallow the use of object properties of the global object (Math
68
- * And JSON) as functions
69
- */
70
- "no-obj-calls": "error",
71
-
72
- // Disallow multiple spaces in a regular expression literal
73
- "no-regex-spaces": "error",
74
-
75
- /*
76
- * This rule disallows sparse array literals which have "holes" where
77
- * Commas are not preceded by elements. It does not apply to a
78
- * Trailing comma following the last element.
79
- */
80
- "no-sparse-arrays": "error",
81
-
82
- /*
83
- * Disallow unreachable statements after a return, throw, continue, or
84
- * Break statement
85
- */
86
- "no-unreachable": "error",
87
-
88
- // Disallow comparisons with the value NaN
89
- "use-isnan": "error",
90
-
91
- /*
92
- * Ensure that the results of typeof are compared against a valid
93
- * String
94
- */
95
- "valid-typeof": "error",
96
-
97
- // Enforces that a return statement is present in property getters
98
- "getter-return": "error",
99
-
100
- /*
101
- * The parseInt() and Number.parseInt() functions can be used to turn
102
- * binary, octal, and hexadecimal strings into integers. As binary,
103
- * octal, and hexadecimal literals are supported in ES6, this rule
104
- * encourages use of those numeric literals instead of parseInt() or
105
- * Number.parseInt().
106
- *
107
- * 0b111110111 === 503; // not parseInt("111110111", 2) === 503;
108
- * 0o767 === 503; // not parseInt("767", 8) === 503;
109
- */
110
- "prefer-numeric-literals": "error",
111
- },
112
- }
package/rules/es6.js DELETED
@@ -1,48 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- // Require braces in arrow function body
4
- "arrow-body-style": ["error", "as-needed"],
5
-
6
- // Verify super() callings in constructors
7
- "constructor-super": 0,
8
-
9
- // Disallow modifying variables of class declarations
10
- "no-class-assign": 0,
11
-
12
- // Disallow modifying variables that are declared using const
13
- "no-const-assign": "error",
14
-
15
- // Disallow duplicate name in class members
16
- "no-dupe-class-members": 0,
17
-
18
- // Disallow to use this/super before super() calling in constructors.
19
- "no-this-before-super": 0,
20
-
21
- // Require let or const instead of var
22
- "no-var": "error",
23
-
24
- // Require method and property shorthand syntax for object literals
25
- "object-shorthand": ["warn", "always"],
26
-
27
- // Suggest using arrow functions as callbacks
28
- "prefer-arrow-callback": "warn",
29
-
30
- /*
31
- * Suggest using of const declaration for variables that are never
32
- * Modified after declared
33
- */
34
- "prefer-const": "error",
35
-
36
- // Suggest using Reflect methods where applicable
37
- "prefer-reflect": 0,
38
-
39
- // Suggest using the spread operator instead of .apply()
40
- "prefer-spread": 0,
41
-
42
- // Suggest using template literals instead of strings concatenation
43
- "prefer-template": "error",
44
-
45
- // Disallow generator functions that do not have yield
46
- "require-yield": 0,
47
- },
48
- }
package/rules/html.js DELETED
@@ -1,59 +0,0 @@
1
- module.exports = {
2
- plugins: ["html"],
3
- settings: {
4
- /*
5
- * By default, this plugin will only consider files ending with those
6
- * extensions as HTML: .erb, .handlebars, .hbs, .htm, .html,
7
- * .mustache, .nunjucks, .php, .tag, .twig, .vue, .we. You can set
8
- * your own list of HTML extensions by using this setting. Example:
9
- */
10
- "html/html-extensions": [
11
- ".erb",
12
- ".handlebars",
13
- ".hbs",
14
- ".htm",
15
- ".html",
16
- ".mustache",
17
- ".nunjucks",
18
- ".php",
19
- ".tag",
20
- ".twig",
21
- ".vue",
22
- ".we",
23
- ],
24
-
25
- /*
26
- * By default, this plugin will only consider files ending with those
27
- * extensions as XML: .xhtml, .xml. You can set your own list of XML
28
- * extensions by using this setting. Example:
29
- */
30
- "html/xml-extensions": [".xhtml", ".xml"],
31
-
32
- /*
33
- * Indentation is the <script> indentation plus two spaces.
34
- */
35
- "html/indent": "+0",
36
-
37
- /*
38
- * By default, this plugin won't warn if it encounters a problematic
39
- * indentation (ex: a line is under indented). If you want to make
40
- * sure the indentation is correct, use the html/report-bad-indent in
41
- * conjunction with the indent rule. Pass "warn" or 1 to display
42
- * warnings, "error" or 2 to display errors. Example:
43
- */
44
- "html/report-bad-indent": "error",
45
-
46
- /*
47
- * By default, the code between <script> tags is considered as
48
- * JavaScript code only if there is no type attribute or if its value
49
- * matches the pattern:
50
- * /^(application|text)\/(x-)?(javascript|babel|ecmascript-6)$/i
51
- *
52
- * You can customize the types that should be considered as JavaScript
53
- * by providing one or multiple MIME types. If a MIME type starts with
54
- * a /, it will be considered as a regular expression.
55
- */
56
- "html/javascript-mime-types":
57
- "/^(application|text)/(x-)?(javascript|babel|ecmascript-6)$/i",
58
- },
59
- }
@@ -1,41 +0,0 @@
1
- module.exports = {
2
- extends: ["plugin:import/typescript"],
3
-
4
- rules: {
5
- /*
6
- * TypeScript compilation already ensures that named imports exist in the
7
- * referenced module
8
- */
9
- "import/named": "off",
10
-
11
- // Typescript handles file resolving
12
- "import/no-unresolved": "off",
13
-
14
- /*
15
- * A list of file extensions that will be parsed as modules and
16
- * inspected for exports.
17
- */
18
- "import/extensions": [
19
- "error",
20
- "always",
21
- {
22
- js: "always",
23
- ts: "never",
24
- },
25
- ],
26
- },
27
-
28
- settings: {
29
- "import/external-module-folders": ["node_modules", "node_modules/@types"],
30
-
31
- "import/parsers": {
32
- "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
33
- },
34
-
35
- "import/resolver": {
36
- node: {
37
- extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
38
- },
39
- },
40
- },
41
- }
package/rules/import.js DELETED
@@ -1,101 +0,0 @@
1
- module.exports = {
2
- plugins: ["import", "no-relative-import-paths"],
3
- extends: ["plugin:import/recommended"],
4
- rules: {
5
- "no-relative-import-paths/no-relative-import-paths": "off",
6
-
7
- /*
8
- * Sort alphabetically, and enforce that all imports are at the top
9
- * of the file.
10
- */
11
- "import/order": [
12
- "error",
13
- {
14
- "newlines-between": "always",
15
- "alphabetize": {
16
- order: "asc",
17
- caseInsensitive: true,
18
- },
19
- },
20
- ],
21
-
22
- /*
23
- * If a default import is requested, this rule will report if there is
24
- * no default export in the imported module.
25
- */
26
- "import/default": "error",
27
-
28
- /*
29
- * Reports funny business with exports, like repeated exports of names
30
- * or defaults.
31
- */
32
- "import/export": "error",
33
-
34
- /*
35
- * Verifies that all named imports are part of the set of named
36
- * exports in the referenced module.
37
- */
38
- "import/named": "error",
39
-
40
- /*
41
- * Enforces names exist at the time they are dereferenced, when
42
- * imported as a full namespace (i.e. import * as foo from './foo';
43
- * foo.bar(); will report if bar is not exported by ./foo.).
44
- */
45
- "import/namespace": [
46
- "error",
47
- {
48
- allowComputed: true,
49
- },
50
- ],
51
-
52
- // Reports if a resolved path is imported more than once.
53
- "import/no-duplicates": "error",
54
-
55
- /*
56
- * Reports use of an exported name as the locally imported name of a
57
- * default export.
58
- */
59
- "import/no-named-as-default": "error",
60
-
61
- // Reports use of an exported name as a property on the default export.
62
- "import/no-named-as-default-member": "error",
63
-
64
- /*
65
- * Ensures an imported module can be resolved to a module on the local
66
- * filesystem, as defined by standard Node require.resolve behavior.
67
- */
68
- "import/no-unresolved": [
69
- "error",
70
- {
71
- commonjs: true,
72
- },
73
- ],
74
-
75
- /*
76
- * Warn if a module could be mistakenly parsed as a script by a
77
- * consumer leveraging Unambiguous JavaScript Grammar to determine
78
- * correct parsing goal.
79
- */
80
- "import/unambiguous": "off",
81
-
82
- /*
83
- * A list of file extensions that will be parsed as modules and
84
- * inspected for exports.
85
- */
86
- "import/extensions": [
87
- "error",
88
- "always",
89
- {
90
- js: "always",
91
- },
92
- ],
93
-
94
- /*
95
- * Enforces that all exports are declared at the bottom of the file.
96
- * This rule will report any export declarations that comes before any
97
- * non-export statements.
98
- */
99
- "import/exports-last": "error",
100
- },
101
- }
package/rules/jsdoc-ts.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- "valid-jsdoc": "off",
4
- "jsdoc/require-param": "off",
5
- "jsdoc/require-returns": "off",
6
- "jsdoc/require-example": "error",
7
- },
8
- }
package/rules/jsdoc.js DELETED
@@ -1,103 +0,0 @@
1
- /*
2
- * JSDoc is a JavaScript API documentation generator. It uses
3
- * specially-formatted comments inside of code to generate API
4
- * documentation automatically.
5
- */
6
-
7
- module.exports = {
8
- plugins: ["jsdoc"],
9
-
10
- extends: ["plugin:eslint-plugin-jsdoc/recommended"],
11
-
12
- rules: {
13
- "require-jsdoc": [
14
- "error",
15
- {
16
- require: {
17
- ArrowFunctionExpression: false,
18
- ClassDeclaration: false,
19
- FunctionDeclaration: true,
20
- MethodDefinition: false,
21
- },
22
- },
23
- ],
24
-
25
- "valid-jsdoc": [
26
- "error",
27
- {
28
- requireParamType: false,
29
- requireParamDescription: false,
30
- requireReturnType: false,
31
- requireReturnDescription: false,
32
-
33
- prefer: {
34
- arg: "param",
35
- argument: "param",
36
- class: "constructor",
37
- return: "returns",
38
- virtual: "abstract",
39
- },
40
-
41
- preferType: {
42
- Boolean: "boolean",
43
- Number: "number",
44
- object: "object",
45
- String: "string",
46
- },
47
- },
48
- ],
49
-
50
- // Allow lines between tags
51
- "jsdoc/tag-lines": "off",
52
-
53
- "jsdoc/check-tag-names": [
54
- "warn",
55
- {
56
- definedTags: [
57
- "tag",
58
- "signature",
59
- "api",
60
- "apiDefine",
61
- "apiDeprecated",
62
- "apiDescription",
63
- "apiError",
64
- "apiErrorExample",
65
- "apiExample",
66
- "apiGroup",
67
- "apiHeader",
68
- "apiHeaderExample",
69
- "apiIgnore",
70
- "apiName",
71
- "apiParam",
72
- "apiParamExample",
73
- "apiPermission",
74
- "apiPrivate",
75
- "apiSampleRequest",
76
- "apiSuccess",
77
- "apiSuccessExample",
78
- "apiUse",
79
- "apiVersion",
80
- ],
81
- },
82
- ],
83
-
84
- // Noise
85
- "jsdoc/require-param-description": "off",
86
- "jsdoc/require-returns-description": "off",
87
- "jsdoc/require-property-description": "off",
88
- "jsdoc/check-types": "off",
89
-
90
- "jsdoc/check-indentation": [
91
- "error",
92
- { excludeTags: ["example", "param", "returns", "type", "typedef"] },
93
- ],
94
-
95
- "jsdoc/check-line-alignment": [
96
- "error",
97
- "always",
98
- {
99
- tags: ["param", "arg", "argument", "property", "prop"],
100
- },
101
- ],
102
- },
103
- }
package/rules/json.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- plugins: ["json"],
3
-
4
- extends: ["plugin:json/recommended"],
5
-
6
- rules: {
7
- "json/colon-expected": "error",
8
- },
9
- }
package/rules/node.js DELETED
@@ -1,56 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- // Enforce return after a callback
4
- "callback-return": 0,
5
-
6
- // Disallow require() outside of the top-level module scope
7
- "global-require": 0,
8
-
9
- // Enforces error handling in callbacks (node environment)
10
- "handle-callback-err": 0,
11
-
12
- /*
13
- * In Node.js, the behavior of the Buffer constructor is different
14
- * depending on the type of its argument. Passing an argument from
15
- * user input to Buffer() without validating its type can lead to
16
- * security vulnerabilities such as remote memory disclosure and
17
- * denial of service. As a result, the Buffer constructor has been
18
- * deprecated and should not be used. Use the producer methods
19
- * Buffer.from, Buffer.alloc, and Buffer.allocUnsafe instead.
20
- */
21
- "no-buffer-constructor": "error",
22
-
23
- // Disallow mixing regular variable and require declarations
24
- "no-mixed-requires": [0, false],
25
-
26
- // Disallow use of new operator with the require function
27
- "no-new-require": 0,
28
-
29
- // Disallow string concatenation with __dirname and __filename
30
- "no-path-concat": 0,
31
-
32
- // Disallow process.exit()
33
- "no-process-exit": 0,
34
-
35
- // Restrict usage of specified node modules
36
- "no-restricted-modules": 0,
37
-
38
- /*
39
- * In Node.js, most I/O is done through asynchronous methods. However,
40
- * there are often synchronous versions of the asynchronous methods.
41
- * For example, fs.exists() and fs.existsSync(). In some contexts,
42
- * using synchronous operations is okay (if, as with ESLint, you are
43
- * writing a command line utility). However, in other contexts the use
44
- * of synchronous operations is considered a bad practice that should
45
- * be avoided. For example, if you are running a high-travel web
46
- * server on Node.js, you should consider carefully if you want to
47
- * allow any synchronous operations that could lock up the server.
48
- */
49
- "no-sync": [
50
- "error",
51
- {
52
- allowAtRootLevel: true,
53
- },
54
- ],
55
- },
56
- }
package/rules/prettier.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- extends: ["plugin:prettier/recommended"],
3
-
4
- rules: {
5
- /**
6
- * If a block (for example after if, else, for or while) contains only one
7
- * statement, JavaScript allows omitting the curly braces around that
8
- * statement. This rule enforces if or when those optional curly
9
- * braces should be omitted.
10
- *
11
- * ! Needs to be Prettier compatible:
12
- * https://github.com/prettier/eslint-config-prettier#curly
13
- */
14
- curly: ["error", "all"],
15
- },
16
- }