@will-stone/eslint-config 0.6.0 → 0.7.1

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @will-stone/eslint-config
2
2
 
3
+ My personal [ESLint](https://eslint.org/) config.
4
+
3
5
  ## Usage
4
6
 
5
7
  ### Install
@@ -55,8 +57,7 @@ the following to your `package.json`:
55
57
  "prepare": "husky install"
56
58
  },
57
59
  "lint-staged": {
58
- "*.{js,jsx,ts,tsx}": ["eslint --fix"],
59
- "*.{css,json,md}": ["prettier --write"]
60
+ "*.{js,jsx,ts,tsx}": ["eslint --fix"]
60
61
  }
61
62
  }
62
63
  ```
package/dist/index.cjs CHANGED
@@ -179,9 +179,7 @@ function base() {
179
179
  "camelcase": "error",
180
180
  // Write comments however you like
181
181
  "capitalized-comments": "off",
182
- // If a class method does not use this,
183
- // it can sometimes be made into a static function
184
- "class-methods-use-this": "error",
182
+ "class-methods-use-this": "off",
185
183
  // Measures the number of linearly independent paths through a program's
186
184
  // source code. Rubbish. Use your own judgement on complexity.
187
185
  "complexity": "off",
@@ -478,6 +476,7 @@ function base() {
478
476
  "no-nonoctal-decimal-escape": "error",
479
477
  // This rule disallows calling the Math, JSON, Reflect and Atomics objects as functions.
480
478
  "no-obj-calls": "error",
479
+ "no-object-constructor": "error",
481
480
  // the leading zero which identifies an octal literal has been a source of
482
481
  // confusion and error in JavaScript code, ECMAScript 5 deprecates the use
483
482
  // of octal numeric literals.
@@ -774,13 +773,13 @@ function ignores() {
774
773
  }
775
774
 
776
775
  // src/configs/imports.ts
777
- var import_eslint_plugin_i = __toESM(require("eslint-plugin-i"), 1);
776
+ var pluginImport = __toESM(require("eslint-plugin-i"), 1);
778
777
  var import_eslint_plugin_simple_import_sort = __toESM(require("eslint-plugin-simple-import-sort"), 1);
779
778
  function imports() {
780
779
  return [
781
780
  {
782
781
  plugins: {
783
- "import": import_eslint_plugin_i.default,
782
+ "import": pluginImport,
784
783
  "simple-import-sort": import_eslint_plugin_simple_import_sort.default
785
784
  },
786
785
  rules: {
@@ -1246,26 +1245,9 @@ function react() {
1246
1245
  "react/jsx-props-no-multi-spaces": "off",
1247
1246
  "react/jsx-tag-spacing": "off",
1248
1247
  "react/jsx-wrap-multilines": "off",
1249
- // It is common to use these lifecycle methods without using "this".
1250
- "class-methods-use-this": [
1251
- "error",
1252
- {
1253
- exceptMethods: [
1254
- "render",
1255
- "getInitialState",
1256
- "getDefaultProps",
1257
- "getChildContext",
1258
- "componentWillMount",
1259
- "componentDidMount",
1260
- "componentWillReceiveProps",
1261
- "shouldComponentUpdate",
1262
- "componentWillUpdate",
1263
- "componentDidUpdate",
1264
- "componentWillUnmount",
1265
- "componentDidCatch"
1266
- ]
1267
- }
1268
- ],
1248
+ /**
1249
+ * React
1250
+ */
1269
1251
  "react/boolean-prop-naming": "error",
1270
1252
  "react/button-has-type": "error",
1271
1253
  "react/default-props-match-prop-types": "error",
@@ -1381,6 +1363,9 @@ function react() {
1381
1363
  "react/static-property-placement": "error",
1382
1364
  "react/style-prop-object": "error",
1383
1365
  "react/void-dom-elements-no-children": "error",
1366
+ /**
1367
+ * Hooks
1368
+ */
1384
1369
  // Checks effect dependencies
1385
1370
  "react-hooks/exhaustive-deps": "warn",
1386
1371
  // Checks rules of Hooks
@@ -1576,6 +1561,7 @@ function typescript() {
1576
1561
  /**
1577
1562
  * Superseded by TS rules below
1578
1563
  */
1564
+ "class-methods-use-this": "off",
1579
1565
  "default-param-last": "off",
1580
1566
  "lines-between-class-members": "off",
1581
1567
  "no-duplicate-imports": "off",
@@ -1599,6 +1585,7 @@ function typescript() {
1599
1585
  "@typescript-eslint/ban-tslint-comment": "warn",
1600
1586
  // Ensures that literals on classes are exposed in a consistent style
1601
1587
  "@typescript-eslint/class-literal-property-style": "warn",
1588
+ "@typescript-eslint/class-methods-use-this": "off",
1602
1589
  // https://typescript-eslint.io/rules/consistent-generic-constructors/
1603
1590
  "@typescript-eslint/consistent-generic-constructors": "warn",
1604
1591
  // Enforce the use of the record type
@@ -2024,22 +2011,23 @@ function unicorn() {
2024
2011
 
2025
2012
  // src/utils.ts
2026
2013
  var import_node_fs = require("fs");
2027
- var import_globby = require("globby");
2028
- var import_load_json_file = require("load-json-file");
2014
+ var import_glob = require("glob");
2015
+ function loadJsonFileSync(filePath) {
2016
+ const buffer = (0, import_node_fs.readFileSync)(filePath);
2017
+ const data = new TextDecoder().decode(buffer);
2018
+ return JSON.parse(data);
2019
+ }
2029
2020
  function checkEnvironment() {
2030
2021
  const isGitIgnore = (0, import_node_fs.existsSync)(".gitignore");
2031
2022
  let isNodeEngine = false;
2032
2023
  let isPrettier = false;
2033
2024
  let isTailwind = false;
2034
2025
  let testingFramework = null;
2035
- const allPackageJsonPaths = (0, import_globby.globbySync)([
2036
- "**/package.json",
2037
- // Could use the `gitIgnore` option but the negative pattern is about 8 times faster.
2038
- // https://github.com/sindresorhus/globby/issues/50
2039
- "!**/node_modules"
2040
- ]);
2026
+ const allPackageJsonPaths = (0, import_glob.globSync)("**/package.json", {
2027
+ ignore: "**/node_modules/**"
2028
+ });
2041
2029
  for (const packageJsonPath of allPackageJsonPaths) {
2042
- const packageJson = (0, import_load_json_file.loadJsonFileSync)(packageJsonPath);
2030
+ const packageJson = loadJsonFileSync(packageJsonPath);
2043
2031
  if (!testingFramework && Boolean(
2044
2032
  packageJson.dependencies?.jest || packageJson.devDependencies?.jest
2045
2033
  )) {
package/dist/index.js CHANGED
@@ -143,9 +143,7 @@ function base() {
143
143
  "camelcase": "error",
144
144
  // Write comments however you like
145
145
  "capitalized-comments": "off",
146
- // If a class method does not use this,
147
- // it can sometimes be made into a static function
148
- "class-methods-use-this": "error",
146
+ "class-methods-use-this": "off",
149
147
  // Measures the number of linearly independent paths through a program's
150
148
  // source code. Rubbish. Use your own judgement on complexity.
151
149
  "complexity": "off",
@@ -442,6 +440,7 @@ function base() {
442
440
  "no-nonoctal-decimal-escape": "error",
443
441
  // This rule disallows calling the Math, JSON, Reflect and Atomics objects as functions.
444
442
  "no-obj-calls": "error",
443
+ "no-object-constructor": "error",
445
444
  // the leading zero which identifies an octal literal has been a source of
446
445
  // confusion and error in JavaScript code, ECMAScript 5 deprecates the use
447
446
  // of octal numeric literals.
@@ -738,7 +737,7 @@ function ignores() {
738
737
  }
739
738
 
740
739
  // src/configs/imports.ts
741
- import pluginImport from "eslint-plugin-i";
740
+ import * as pluginImport from "eslint-plugin-i";
742
741
  import pluginSimpleImport from "eslint-plugin-simple-import-sort";
743
742
  function imports() {
744
743
  return [
@@ -1210,26 +1209,9 @@ function react() {
1210
1209
  "react/jsx-props-no-multi-spaces": "off",
1211
1210
  "react/jsx-tag-spacing": "off",
1212
1211
  "react/jsx-wrap-multilines": "off",
1213
- // It is common to use these lifecycle methods without using "this".
1214
- "class-methods-use-this": [
1215
- "error",
1216
- {
1217
- exceptMethods: [
1218
- "render",
1219
- "getInitialState",
1220
- "getDefaultProps",
1221
- "getChildContext",
1222
- "componentWillMount",
1223
- "componentDidMount",
1224
- "componentWillReceiveProps",
1225
- "shouldComponentUpdate",
1226
- "componentWillUpdate",
1227
- "componentDidUpdate",
1228
- "componentWillUnmount",
1229
- "componentDidCatch"
1230
- ]
1231
- }
1232
- ],
1212
+ /**
1213
+ * React
1214
+ */
1233
1215
  "react/boolean-prop-naming": "error",
1234
1216
  "react/button-has-type": "error",
1235
1217
  "react/default-props-match-prop-types": "error",
@@ -1345,6 +1327,9 @@ function react() {
1345
1327
  "react/static-property-placement": "error",
1346
1328
  "react/style-prop-object": "error",
1347
1329
  "react/void-dom-elements-no-children": "error",
1330
+ /**
1331
+ * Hooks
1332
+ */
1348
1333
  // Checks effect dependencies
1349
1334
  "react-hooks/exhaustive-deps": "warn",
1350
1335
  // Checks rules of Hooks
@@ -1540,6 +1525,7 @@ function typescript() {
1540
1525
  /**
1541
1526
  * Superseded by TS rules below
1542
1527
  */
1528
+ "class-methods-use-this": "off",
1543
1529
  "default-param-last": "off",
1544
1530
  "lines-between-class-members": "off",
1545
1531
  "no-duplicate-imports": "off",
@@ -1563,6 +1549,7 @@ function typescript() {
1563
1549
  "@typescript-eslint/ban-tslint-comment": "warn",
1564
1550
  // Ensures that literals on classes are exposed in a consistent style
1565
1551
  "@typescript-eslint/class-literal-property-style": "warn",
1552
+ "@typescript-eslint/class-methods-use-this": "off",
1566
1553
  // https://typescript-eslint.io/rules/consistent-generic-constructors/
1567
1554
  "@typescript-eslint/consistent-generic-constructors": "warn",
1568
1555
  // Enforce the use of the record type
@@ -1987,21 +1974,22 @@ function unicorn() {
1987
1974
  }
1988
1975
 
1989
1976
  // src/utils.ts
1990
- import { existsSync } from "fs";
1991
- import { globbySync } from "globby";
1992
- import { loadJsonFileSync } from "load-json-file";
1977
+ import { existsSync, readFileSync } from "fs";
1978
+ import { globSync } from "glob";
1979
+ function loadJsonFileSync(filePath) {
1980
+ const buffer = readFileSync(filePath);
1981
+ const data = new TextDecoder().decode(buffer);
1982
+ return JSON.parse(data);
1983
+ }
1993
1984
  function checkEnvironment() {
1994
1985
  const isGitIgnore = existsSync(".gitignore");
1995
1986
  let isNodeEngine = false;
1996
1987
  let isPrettier = false;
1997
1988
  let isTailwind = false;
1998
1989
  let testingFramework = null;
1999
- const allPackageJsonPaths = globbySync([
2000
- "**/package.json",
2001
- // Could use the `gitIgnore` option but the negative pattern is about 8 times faster.
2002
- // https://github.com/sindresorhus/globby/issues/50
2003
- "!**/node_modules"
2004
- ]);
1990
+ const allPackageJsonPaths = globSync("**/package.json", {
1991
+ ignore: "**/node_modules/**"
1992
+ });
2005
1993
  for (const packageJsonPath of allPackageJsonPaths) {
2006
1994
  const packageJson = loadJsonFileSync(packageJsonPath);
2007
1995
  if (!testingFramework && Boolean(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@will-stone/eslint-config",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Will Stone's ESLint config",
5
5
  "keywords": [
6
6
  "eslint-config"
@@ -61,6 +61,7 @@
61
61
  "eslint-plugin-switch-case": "^1.1.2",
62
62
  "eslint-plugin-tailwindcss": "^3.13.0",
63
63
  "eslint-plugin-unicorn": "^48.0.1",
64
+ "glob": "^10.3.10",
64
65
  "globals": "^13.22.0",
65
66
  "globby": "^13.2.2",
66
67
  "load-json-file": "^7.0.1"
@@ -72,7 +73,7 @@
72
73
  "@types/node": "^20.8.2",
73
74
  "@will-stone/prettier-config": "^7.0.1",
74
75
  "eslint": "^8.50.0",
75
- "eslint-flat-config-viewer": "^0.0.8",
76
+ "eslint-flat-config-viewer": "^0.0.9",
76
77
  "husky": "^8.0.3",
77
78
  "lint-staged": "^14.0.1",
78
79
  "prettier": "^3.0.3",