@storm-software/eslint 0.22.0 → 0.23.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.
package/dist/preset.mjs CHANGED
@@ -8,6 +8,8 @@ import react from 'eslint-plugin-react';
8
8
  import jsxA11y from 'eslint-plugin-jsx-a11y';
9
9
  import reactHooks from 'eslint-plugin-react-hooks';
10
10
  import tsdoc from 'eslint-plugin-tsdoc';
11
+ import prettierConfig from 'eslint-plugin-prettier/recommended';
12
+ import { config as config$5, rules } from 'eslint-plugin-import';
11
13
 
12
14
  function getDefaultExportFromCjs (x) {
13
15
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -346,7 +348,7 @@ const formatConfig = (name, config = []) => {
346
348
  });
347
349
  };
348
350
 
349
- const config$3 = {
351
+ const config$4 = {
350
352
  // This rule has been deprecated, but not yet removed.
351
353
  "jsx-a11y/no-onchange": "off",
352
354
  // ensure emoji are accessible
@@ -621,7 +623,7 @@ const config$3 = {
621
623
  "jsx-a11y/prefer-tag-over-role": "off"
622
624
  };
623
625
 
624
- const config$2 = {
626
+ const config$3 = {
625
627
  // We recommend using TypeScript over `prop-types`, as `prop-types` can add
626
628
  // to a project's build size.
627
629
  "react/prop-types": "off",
@@ -1186,7 +1188,7 @@ const config$2 = {
1186
1188
  ]
1187
1189
  };
1188
1190
 
1189
- const config$1 = {
1191
+ const config$2 = {
1190
1192
  // Enforce Rules of Hooks
1191
1193
  // https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
1192
1194
  "react-hooks/rules-of-hooks": "error",
@@ -1195,7 +1197,7 @@ const config$1 = {
1195
1197
  "react-hooks/exhaustive-deps": "warn"
1196
1198
  };
1197
1199
 
1198
- const config = {
1200
+ const config$1 = {
1199
1201
  /**
1200
1202
  * Require TSDoc comments conform to the TSDoc specification.
1201
1203
  *
@@ -1204,6 +1206,296 @@ const config = {
1204
1206
  "tsdoc/syntax": "error"
1205
1207
  };
1206
1208
 
1209
+ const importEslint = {
1210
+ meta: {
1211
+ name: "eslint-plugin-import",
1212
+ version: "2.29.1"
1213
+ },
1214
+ configs: {
1215
+ ...config$5
1216
+ },
1217
+ rules: {
1218
+ ...rules
1219
+ },
1220
+ processors: {}
1221
+ };
1222
+
1223
+ const config = {
1224
+ /**
1225
+ * Disallow non-import statements appearing before import statements.
1226
+ *
1227
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
1228
+ */
1229
+ "import/first": "warn",
1230
+ /**
1231
+ * Require a newline after the last import/require.
1232
+ *
1233
+ * 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md
1234
+ */
1235
+ "import/newline-after-import": "warn",
1236
+ /**
1237
+ * Disallow import of modules using absolute paths.
1238
+ *
1239
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md
1240
+ */
1241
+ "import/no-absolute-path": "error",
1242
+ /**
1243
+ * Disallow default exports.
1244
+ *
1245
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
1246
+ */
1247
+ "import/no-default-export": "error",
1248
+ /**
1249
+ * Disallow the use of extraneous packages.
1250
+ *
1251
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
1252
+ */
1253
+ "import/no-extraneous-dependencies": [
1254
+ "error",
1255
+ { includeInternal: true, includeTypes: true }
1256
+ ],
1257
+ /**
1258
+ * Disallow mutable exports.
1259
+ *
1260
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md
1261
+ */
1262
+ "import/no-mutable-exports": "error",
1263
+ /**
1264
+ * Disallow importing packages through relative paths.
1265
+ *
1266
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-packages.md
1267
+ */
1268
+ "import/no-relative-packages": "warn",
1269
+ /**
1270
+ * Disallow a module from importing itself.
1271
+ *
1272
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md
1273
+ */
1274
+ "import/no-self-import": "error",
1275
+ /**
1276
+ * Ensures that there are no useless path segments.
1277
+ *
1278
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-useless-path-segments.md
1279
+ */
1280
+ "import/no-useless-path-segments": ["error"],
1281
+ /**
1282
+ * Enforce a module import order convention.
1283
+ *
1284
+ * 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
1285
+ */
1286
+ "import/order": [
1287
+ "warn",
1288
+ {
1289
+ groups: [
1290
+ "builtin",
1291
+ // Node.js built-in modules
1292
+ "external",
1293
+ // Packages
1294
+ "internal",
1295
+ // Aliased modules
1296
+ "parent",
1297
+ // Relative parent
1298
+ "sibling",
1299
+ // Relative sibling
1300
+ "index"
1301
+ // Relative index
1302
+ ],
1303
+ "newlines-between": "never"
1304
+ }
1305
+ ],
1306
+ "import/extensions": ["error", "ignorePackages"],
1307
+ // Bob when bundling requires to have `.js` extension
1308
+ "import/prefer-default-export": "off",
1309
+ // disable opposite of 'import/no-default-export'
1310
+ // Reports any imports that come after non-import statements
1311
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
1312
+ "import/no-duplicates": "error",
1313
+ // ensure imports point to files/modules that can be resolved
1314
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
1315
+ "import/no-unresolved": "off",
1316
+ // ensure named imports coupled with named exports
1317
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
1318
+ "import/named": "error",
1319
+ // ensure default import coupled with default export
1320
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
1321
+ "import/default": "off",
1322
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/namespace.md
1323
+ "import/namespace": "off",
1324
+ // Helpful warnings:
1325
+ // disallow invalid exports, e.g. multiple defaults
1326
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md
1327
+ "import/export": "error",
1328
+ // do not allow a default import name to match a named export
1329
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
1330
+ "import/no-named-as-default": "error",
1331
+ // warn on accessing default export property names that are also named exports
1332
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
1333
+ "import/no-named-as-default-member": "error",
1334
+ // disallow use of jsdoc-marked-deprecated imports
1335
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
1336
+ "import/no-deprecated": "off",
1337
+ // Forbid the use of extraneous packages
1338
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
1339
+ // paths are treated both as absolute paths, and relative to process.cwd()
1340
+ // "import/no-extraneous-dependencies": [
1341
+ // "error",
1342
+ // {
1343
+ // devDependencies: [
1344
+ // "test/**", // tape, common npm pattern
1345
+ // "tests/**", // also common npm pattern
1346
+ // "spec/**", // mocha, rspec-like pattern
1347
+ // "**/__tests__/**", // jest pattern
1348
+ // "**/__mocks__/**", // jest pattern
1349
+ // "test.{js,jsx}", // repos with a single test file
1350
+ // "test-*.{js,jsx}", // repos with multiple top-level test files
1351
+ // "**/*{.,_}{test,spec}.{js,jsx}", // tests where the extension or filename suffix denotes that it is a test
1352
+ // "**/jest.config.js", // jest config
1353
+ // "**/jest.setup.js", // jest setup
1354
+ // "**/vue.config.js", // vue-cli config
1355
+ // "**/webpack.config.js", // webpack config
1356
+ // "**/webpack.config.*.js", // webpack config
1357
+ // "**/rollup.config.js", // rollup config
1358
+ // "**/rollup.config.*.js", // rollup config
1359
+ // "**/gulpfile.js", // gulp config
1360
+ // "**/gulpfile.*.js", // gulp config
1361
+ // "**/Gruntfile{,.js}", // grunt config
1362
+ // "**/protractor.conf.js", // protractor config
1363
+ // "**/protractor.conf.*.js", // protractor config
1364
+ // "**/karma.conf.js", // karma config
1365
+ // "**/.eslintrc.js" // eslint config
1366
+ // ],
1367
+ // optionalDependencies: false
1368
+ // }
1369
+ // ],
1370
+ // Module systems:
1371
+ // disallow require()
1372
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
1373
+ "import/no-commonjs": "off",
1374
+ // disallow AMD require/define
1375
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md
1376
+ "import/no-amd": "error",
1377
+ // No Node.js builtin modules
1378
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
1379
+ // TODO: enable?
1380
+ "import/no-nodejs-modules": "off",
1381
+ // Style guide:
1382
+ // disallow non-import statements appearing before import statements
1383
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/imports-first.md
1384
+ // deprecated: use `import/first`
1385
+ "import/imports-first": "off",
1386
+ // disallow namespace imports
1387
+ // TODO: enable?
1388
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
1389
+ "import/no-namespace": "off",
1390
+ // Restrict which files can be imported in a given folder
1391
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
1392
+ "import/no-restricted-paths": "off",
1393
+ // Forbid modules to have too many dependencies
1394
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
1395
+ "import/max-dependencies": ["warn", { max: 50 }],
1396
+ // Forbid require() calls with expressions
1397
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
1398
+ "import/no-dynamic-require": "error",
1399
+ // prevent importing the submodules of other modules
1400
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
1401
+ "import/no-internal-modules": [
1402
+ "off",
1403
+ {
1404
+ allow: []
1405
+ }
1406
+ ],
1407
+ // Warn if a module could be mistakenly parsed as a script by a consumer
1408
+ // leveraging Unambiguous JavaScript Grammar
1409
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
1410
+ // this should not be enabled until this proposal has at least been *presented* to TC39.
1411
+ // At the moment, it's not a thing.
1412
+ "import/unambiguous": "off",
1413
+ // Forbid Webpack loader syntax in imports
1414
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
1415
+ "import/no-webpack-loader-syntax": "error",
1416
+ // Prevent unassigned imports
1417
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
1418
+ // importing for side effects is perfectly acceptable, if you need side effects.
1419
+ "import/no-unassigned-import": "off",
1420
+ // Prevent importing the default as if it were named
1421
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
1422
+ "import/no-named-default": "error",
1423
+ // Reports if a module's default export is unnamed
1424
+ // https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
1425
+ "import/no-anonymous-default-export": [
1426
+ "off",
1427
+ {
1428
+ allowArray: false,
1429
+ allowArrowFunction: false,
1430
+ allowAnonymousClass: false,
1431
+ allowAnonymousFunction: false,
1432
+ allowLiteral: false,
1433
+ allowObject: false
1434
+ }
1435
+ ],
1436
+ // This rule enforces that all exports are declared at the bottom of the file.
1437
+ // https://github.com/import-js/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
1438
+ // TODO: enable?
1439
+ "import/exports-last": "off",
1440
+ // Reports when named exports are not grouped together in a single export declaration
1441
+ // or when multiple assignments to CommonJS module.exports or exports object are present
1442
+ // in a single file.
1443
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
1444
+ "import/group-exports": "off",
1445
+ // Prohibit named exports. this is a terrible rule, do not use it.
1446
+ // https://github.com/import-js/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
1447
+ "import/no-named-export": "off",
1448
+ /**
1449
+ * Disallow cyclical dependencies between modules.
1450
+ *
1451
+ * 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
1452
+ */
1453
+ "import/no-cycle": ["error", { maxDepth: "\u221E" }],
1454
+ // dynamic imports require a leading comment with a webpackChunkName
1455
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
1456
+ "import/dynamic-import-chunkname": [
1457
+ "off",
1458
+ {
1459
+ importFunctions: [],
1460
+ webpackChunknameFormat: "[0-9a-zA-Z-_/.]+"
1461
+ }
1462
+ ],
1463
+ // Use this rule to prevent imports to folders in relative parent paths.
1464
+ // https://github.com/import-js/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
1465
+ "import/no-relative-parent-imports": "off",
1466
+ // Reports modules without any exports, or with unused exports
1467
+ // https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
1468
+ // TODO: enable once it supports CJS
1469
+ "import/no-unused-modules": [
1470
+ "off",
1471
+ {
1472
+ ignoreExports: [],
1473
+ missingExports: true,
1474
+ unusedExports: true
1475
+ }
1476
+ ],
1477
+ // Reports the use of import declarations with CommonJS exports in any module except for the main module.
1478
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
1479
+ "import/no-import-module-exports": [
1480
+ "error",
1481
+ {
1482
+ exceptions: []
1483
+ }
1484
+ ],
1485
+ // enforce a consistent style for type specifiers (inline or top-level)
1486
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/consistent-type-specifier-style.md
1487
+ // TODO, semver-major: enable (just in case)
1488
+ "import/consistent-type-specifier-style": ["off", "prefer-inline"],
1489
+ // Reports the use of empty named import blocks.
1490
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
1491
+ // TODO, semver-minor: enable
1492
+ "import/no-empty-named-blocks": "off"
1493
+ };
1494
+
1495
+ const CODE_BLOCK = "**/*.md{,x}/*";
1496
+ const CODE_FILE = "**/*.{,c,m}{j,t}s{,x}";
1497
+ const TS_FILE = "**/*.{,c,m}ts{,x}";
1498
+
1207
1499
  function stormPreset(options = {
1208
1500
  moduleBoundaries: {
1209
1501
  enforceBuildableLibDependency: true,
@@ -1246,6 +1538,8 @@ function stormPreset(options = {
1246
1538
  ...tsEslint.configs.recommended,
1247
1539
  // https://github.com/sindresorhus/eslint-plugin-unicorn
1248
1540
  eslintPluginUnicorn.configs["flat/recommended"],
1541
+ // Prettier
1542
+ prettierConfig,
1249
1543
  // Preset overrides
1250
1544
  { rules },
1251
1545
  {
@@ -1265,7 +1559,7 @@ function stormPreset(options = {
1265
1559
  // https://www.npmjs.com/package/eslint-plugin-markdown
1266
1560
  options.markdown !== false && { plugins: { markdown } },
1267
1561
  options.markdown !== false && {
1268
- files: ["*.md"],
1562
+ files: [CODE_BLOCK],
1269
1563
  processor: "markdown/markdown"
1270
1564
  },
1271
1565
  options.markdown !== false && {
@@ -1288,22 +1582,27 @@ function stormPreset(options = {
1288
1582
  plugins: { react, "react-hooks": reactHooks, "jsx-a11y": jsxA11y }
1289
1583
  },
1290
1584
  options.react !== false && {
1291
- files: ["*.ts", "*.tsx", "*.js", "*.jsx"],
1585
+ files: [CODE_FILE],
1292
1586
  rules: {
1293
- ...config$2,
1294
- ...config$1,
1295
1587
  ...config$3,
1588
+ ...config$2,
1589
+ ...config$4,
1296
1590
  ...options.react?.rules
1297
1591
  }
1298
1592
  },
1593
+ // Import
1594
+ // https://www.npmjs.com/package/eslint-plugin-import
1595
+ { plugins: { import: importEslint } },
1596
+ {
1597
+ files: [CODE_FILE],
1598
+ rules: config
1599
+ },
1299
1600
  // TSDoc
1300
1601
  // https://www.npmjs.com/package/eslint-plugin-tsdoc
1301
1602
  { plugins: { tsdoc } },
1302
1603
  {
1303
- files: ["*.ts", "*.tsx"],
1304
- rules: {
1305
- ...config
1306
- }
1604
+ files: [TS_FILE],
1605
+ rules: config$1
1307
1606
  },
1308
1607
  // Nx plugin
1309
1608
  { plugins: { "@nx": nxPlugin } },
@@ -1316,15 +1615,7 @@ function stormPreset(options = {
1316
1615
  },
1317
1616
  rules: {
1318
1617
  "@typescript-eslint/explicit-module-boundary-types": "off",
1319
- "@typescript-eslint/explicit-function-return-type": [
1320
- "warn",
1321
- {
1322
- allowExpressions: true,
1323
- allowConciseArrowFunctionExpressionsStartingWithVoid: true,
1324
- allowFunctionsWithoutTypeParameters: true,
1325
- allowIIFEs: true
1326
- }
1327
- ]
1618
+ "@typescript-eslint/explicit-function-return-type": "off"
1328
1619
  }
1329
1620
  },
1330
1621
  {
@@ -1335,12 +1626,13 @@ function stormPreset(options = {
1335
1626
  rules: {}
1336
1627
  },
1337
1628
  {
1338
- files: ["*.ts", "*.tsx", "*.js", "*.jsx"],
1629
+ files: [CODE_FILE],
1339
1630
  rules: {
1340
1631
  "@nx/enforce-module-boundaries": [
1341
1632
  "error",
1342
1633
  options.moduleBoundaries ? options.moduleBoundaries : {
1343
1634
  enforceBuildableLibDependency: true,
1635
+ checkDynamicDependenciesExceptions: [".*"],
1344
1636
  allow: [],
1345
1637
  depConstraints: [
1346
1638
  {
@@ -1349,6 +1641,22 @@ function stormPreset(options = {
1349
1641
  }
1350
1642
  ]
1351
1643
  }
1644
+ ],
1645
+ "no-restricted-imports": ["error", "create-nx-workspace"],
1646
+ "@typescript-eslint/no-restricted-imports": [
1647
+ "error",
1648
+ {
1649
+ "patterns": [
1650
+ {
1651
+ "group": ["nx/src/plugins/js*"],
1652
+ "message": "Imports from 'nx/src/plugins/js' are not allowed. Use '@nx/js' instead"
1653
+ },
1654
+ {
1655
+ "group": ["**/native-bindings", "**/native-bindings.js", ""],
1656
+ "message": "Direct imports from native-bindings.js are not allowed. Import from index.js instead."
1657
+ }
1658
+ ]
1659
+ }
1352
1660
  ]
1353
1661
  }
1354
1662
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/eslint",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "description": "⚡ A package containing the base ESLint configuration used by Storm Software across many projects.",
6
6
  "repository": {
@@ -69,12 +69,14 @@
69
69
  "@graphql-eslint/eslint-plugin": "3.20.1",
70
70
  "@next/eslint-plugin-next": "14.2.4",
71
71
  "eslint-plugin-es-x": "7.6.0",
72
+ "eslint-plugin-import": "^2.29.1",
72
73
  "eslint-plugin-jsonc": "2.16.0",
73
74
  "eslint-plugin-jsx-a11y": "6.8.0",
74
75
  "eslint-plugin-markdown": "^5.1.0",
75
76
  "eslint-plugin-markdownlint": "0.6.0",
76
77
  "eslint-plugin-mdx": "3.1.5",
77
78
  "eslint-plugin-n": "17.8.1",
79
+ "eslint-plugin-prettier": "^5.0.0",
78
80
  "eslint-plugin-promise": "6.2.0",
79
81
  "eslint-plugin-react": "7.34.3",
80
82
  "eslint-plugin-react-hooks": "4.6.2",