@cabify/eslint-config 3.0.1-beta-6 → 3.0.1-beta-9

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/configs/base.js CHANGED
@@ -1,28 +1,30 @@
1
- const globals = require('globals');
1
+ /* eslint-disable import/extensions */
2
+ import globals from 'globals';
2
3
 
3
- const { isPackageAvailable } = require('../utils');
4
+ import { isPackageAvailable } from '../utils.js';
5
+ import bestPractices from './best-practices.js';
6
+ import errors from './errors.js';
7
+ import es6 from './es6.js';
8
+ import formats from './formats.js';
9
+ import imports from './imports.js';
10
+ import jest from './jest.js';
11
+ import lodash from './lodash.js';
12
+ import node from './node.js';
13
+ import postcss from './postcss.js';
14
+ import promises from './promises.js';
15
+ import react from './react.js';
16
+ import reactA11y from './react-a11y.js';
17
+ import storybook from './storybook.js';
18
+ import strict from './strict.js';
19
+ import style from './style.js';
20
+ import variables from './variables.js';
4
21
 
5
- const isTSAvailable = isPackageAvailable('typescript');
6
- const isJestAvailable = isPackageAvailable('jest');
7
-
8
- const storybook = require('./storybook');
9
- const ts = require('./ts');
10
- const postcss = require('./postcss');
11
-
12
- const bestPractices = require('./best-practices');
13
- const errors = require('./errors');
14
- const es6 = require('./es6');
15
- const imports = require('./imports');
16
- const node = require('./node');
17
- const promises = require('./promises');
18
- const strict = require('./strict');
19
- const style = require('./style');
20
- const variables = require('./variables');
21
- const react = require('./react');
22
- const lodash = require('./lodash');
23
- const reactA11y = require('./react-a11y');
24
- const jest = require('./jest');
25
- const formats = require('./formats');
22
+ const isTSAvailable = await isPackageAvailable('typescript');
23
+ let tsConfigs = [];
24
+ if (isTSAvailable) {
25
+ tsConfigs = await import('./ts.js');
26
+ }
27
+ const isJestAvailable = await isPackageAvailable('jest');
26
28
 
27
29
  const configs = [
28
30
  bestPractices,
@@ -42,10 +44,6 @@ const configs = [
42
44
  ].filter(Boolean);
43
45
 
44
46
  const overrides = [
45
- isTSAvailable && {
46
- files: ['**/*.ts', '**/*.tsx'],
47
- ...ts,
48
- },
49
47
  {
50
48
  files: ['*.story.tsx', '*.stories.tsx'],
51
49
  ...storybook,
@@ -56,7 +54,7 @@ const overrides = [
56
54
  },
57
55
  ].filter(Boolean);
58
56
 
59
- module.exports = [
57
+ export default [
60
58
  ...configs,
61
59
  {
62
60
  name: 'base-cabify-eslint-config',
@@ -72,5 +70,6 @@ module.exports = [
72
70
  strict: 'error',
73
71
  },
74
72
  },
73
+ ...tsConfigs,
75
74
  ...overrides,
76
75
  ];
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'best-practices-cabify-eslint-config',
3
3
  rules: {
4
4
  // enforces getter/setter pairs in objects
package/configs/errors.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'errors-cabify-eslint-config',
3
3
  rules: {
4
4
  // Enforce “for” loop update clause moving the counter in the right direction
package/configs/es6.js CHANGED
@@ -1,18 +1,20 @@
1
- module.exports = {
1
+ import globals from 'globals';
2
+
3
+ export default {
2
4
  name: 'ES6-cabify-eslint-config',
3
- // languageOptions: {
4
- // globals: {
5
- // es6: true,
6
- // },
7
- // ecmaVersion: 6,
8
- // sourceType: 'module',
9
- // parserOptions: {
10
- // ecmaFeatures: {
11
- // generators: false,
12
- // objectLiteralDuplicateProperties: false,
13
- // },
14
- // },
15
- // },
5
+ languageOptions: {
6
+ ecmaVersion: 6,
7
+ sourceType: 'module',
8
+ globals: {
9
+ ...globals.es2015,
10
+ },
11
+ parserOptions: {
12
+ ecmaFeatures: {
13
+ generators: false,
14
+ objectLiteralDuplicateProperties: false,
15
+ },
16
+ },
17
+ },
16
18
 
17
19
  rules: {
18
20
  // verify super() callings in constructors
@@ -1,6 +1,6 @@
1
- const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
1
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  name: 'formats-cabify-eslint-config',
5
5
  ...eslintPluginPrettierRecommended,
6
6
  };
@@ -1,13 +1,14 @@
1
- const importPlugin = require('eslint-plugin-import');
2
- const simpleImportSort = require('eslint-plugin-simple-import-sort');
1
+ import importPlugin from 'eslint-plugin-import';
2
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
3
+ import globals from 'globals';
3
4
 
4
- module.exports = {
5
+ export default {
5
6
  name: 'imports-cabify-eslint-config',
6
- // languageOptions: {
7
- // globals: {
8
- // es6: true,
9
- // },
10
- // },
7
+ languageOptions: {
8
+ globals: {
9
+ ...globals.es2015,
10
+ },
11
+ },
11
12
  plugins: {
12
13
  import: importPlugin,
13
14
  'simple-import-sort': simpleImportSort,
package/configs/jest.js CHANGED
@@ -1,6 +1,6 @@
1
- const jest = require('eslint-plugin-jest');
1
+ import jest from 'eslint-plugin-jest';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  name: 'jest-cabify-eslint-config',
5
5
  ...jest.configs['flat/recommended'],
6
6
  rules: {
package/configs/lodash.js CHANGED
@@ -1,6 +1,6 @@
1
- const lodashPlugin = require('eslint-plugin-lodash');
1
+ import lodashPlugin from 'eslint-plugin-lodash';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  name: 'lodash-cabify-eslint-config',
5
5
  plugins: { lodash: lodashPlugin },
6
6
  rules: {
package/configs/node.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'node-cabify-eslint-config',
3
3
  rules: {
4
4
  // enforce return after a callback
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'post-css-cabify-eslint-config',
3
3
  rules: {
4
4
  'global-require': 'off',
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'promises-cabify-eslint-config',
3
3
  rules: {
4
4
  'no-floating-promises': 'off',
@@ -1,17 +1,15 @@
1
- const jsxAllyPlugin = require('eslint-plugin-jsx-a11y');
1
+ import jsxAllyPlugin from 'eslint-plugin-jsx-a11y';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  name: 'react-a11y-cabify-eslint-config',
5
5
  plugins: { 'jsx-a11y': jsxAllyPlugin },
6
-
7
- // languageOptions: {
8
- // parserOptions: {
9
- // ecmaFeatures: {
10
- // jsx: true,
11
- // },
12
- // },
13
- // },
14
-
6
+ languageOptions: {
7
+ parserOptions: {
8
+ ecmaFeatures: {
9
+ jsx: true,
10
+ },
11
+ },
12
+ },
15
13
  rules: {
16
14
  // Enforce that anchors have content
17
15
  // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
package/configs/react.js CHANGED
@@ -1,7 +1,7 @@
1
- const react = require('eslint-plugin-react');
2
- const reactHooks = require('eslint-plugin-react-hooks');
1
+ import react from 'eslint-plugin-react';
2
+ import reactHooks from 'eslint-plugin-react-hooks';
3
3
 
4
- module.exports = {
4
+ export default {
5
5
  name: 'react-cabify-eslint-config',
6
6
  plugins: {
7
7
  react,
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'storybook-cabify-eslint-config',
3
3
  rules: {
4
4
  'import/no-default-export': 'off',
package/configs/strict.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'strict-cabify-eslint-config',
3
3
  rules: {
4
4
  // babel inserts `'use strict';` for us
package/configs/style.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  name: 'style-cabify-eslint-config',
3
3
  rules: {
4
4
  // require camel case names
package/configs/ts.js CHANGED
@@ -1,10 +1,10 @@
1
- module.exports = {
1
+ /* eslint-disable import/no-unresolved */
2
+ /* eslint-disable no-param-reassign */
3
+ import tseslint from 'typescript-eslint';
4
+
5
+ const tsCustomConfig = {
2
6
  name: 'ts-cabify-eslint-config',
3
- plugins: ['@typescript-eslint'],
4
- extends: [
5
- 'plugin:@typescript-eslint/recommended',
6
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
7
- ],
7
+ files: ['**/*.ts', '**/*.tsx'],
8
8
  rules: {
9
9
  '@typescript-eslint/restrict-template-expressions': [
10
10
  'error',
@@ -136,9 +136,26 @@ module.exports = {
136
136
  'no-redeclare': 'off', // superseeded by @typescript-eslint/no-redeclare
137
137
  'no-shadow': 'off', // superseeded by @typescript-eslint/no-shadow
138
138
  },
139
- overrides: [
140
- {
141
- excludedFiles: '*.d.ts',
139
+ languageOptions: {
140
+ parserOptions: {
141
+ projectService: true,
142
+ tsconfigRootDir: import.meta.dirname,
142
143
  },
143
- ],
144
+ },
145
+ ignores: ['*.d.ts'],
144
146
  };
147
+
148
+ const tsLintConfig = tseslint.config(
149
+ ...tseslint.configs.recommended,
150
+ ...tseslint.configs.recommendedTypeChecked,
151
+ { ...tsCustomConfig },
152
+ );
153
+
154
+ if (tsLintConfig.length) {
155
+ tsLintConfig.forEach((tsconfig) => {
156
+ tsconfig.files = ['**/*.ts', '**/*.tsx'];
157
+ tsconfig.ignores = ['**/*.d.ts'];
158
+ });
159
+ }
160
+
161
+ export default tsLintConfig;
@@ -1,6 +1,6 @@
1
- const confusingBrowserGlobals = require('confusing-browser-globals');
1
+ import confusingBrowserGlobals from 'confusing-browser-globals';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  name: 'variables-cabify-eslint-config',
5
5
  rules: {
6
6
  // enforce or disallow variable initializations at definition
package/eslint.config.js CHANGED
@@ -1,3 +1,4 @@
1
- const recommended = require('./recommended');
1
+ // eslint-disable-next-line import/extensions
2
+ import recommended from './recommended.js';
2
3
 
3
- module.exports = [...recommended];
4
+ export default [...recommended];
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@cabify/eslint-config",
3
- "version": "3.0.1-beta-6",
3
+ "version": "3.0.1-beta-9",
4
4
  "description": "ESLint config for Cabify Javascript projects",
5
+ "type": "module",
5
6
  "scripts": {
6
7
  "build": "echo 'No build to perform'",
7
8
  "test": "npm run lint:check && npm run format:check",
@@ -38,7 +39,6 @@
38
39
  ".": "./recommended.js"
39
40
  },
40
41
  "dependencies": {
41
- "@typescript-eslint/eslint-plugin": "^8.4.0",
42
42
  "@typescript-eslint/parser": "^8.4.0",
43
43
  "confusing-browser-globals": "^1.0.10",
44
44
  "eslint-config-prettier": "^9.1.0",
@@ -50,14 +50,15 @@
50
50
  "eslint-plugin-react": "^7.36.0",
51
51
  "eslint-plugin-react-hooks": "^4.6.2",
52
52
  "eslint-plugin-simple-import-sort": "^12.1.1",
53
- "globals": "^15.9.0"
53
+ "globals": "^15.9.0",
54
+ "typescript-eslint": "^8.8.0"
54
55
  },
55
56
  "peerDependencies": {
56
- "eslint": "9.11.0",
57
+ "eslint": ">= 9.11.0",
57
58
  "prettier": ">= 2.2.1"
58
59
  },
59
60
  "devDependencies": {
60
- "eslint": "9.11.0",
61
+ "eslint": "^9.11.1",
61
62
  "prettier": "3.3.3"
62
63
  },
63
64
  "publishConfig": {
package/recommended.js CHANGED
@@ -1,4 +1,6 @@
1
- const base = require('./configs/base');
2
- const eslintConfigPrettier = require('eslint-config-prettier');
1
+ import eslintConfigPrettier from 'eslint-config-prettier';
3
2
 
4
- module.exports = [...base, eslintConfigPrettier];
3
+ // eslint-disable-next-line import/extensions
4
+ import base from './configs/base.js';
5
+
6
+ export default [...base, eslintConfigPrettier];
package/utils.js CHANGED
@@ -1,11 +1,11 @@
1
- module.exports = {
2
- isPackageAvailable(packageName) {
3
- try {
4
- // eslint-disable-next-line global-require, import/no-dynamic-require
5
- return !!require(packageName);
6
- // eslint-disable-next-line no-unused-vars
7
- } catch (e) {
8
- return false;
9
- }
10
- },
11
- };
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export async function isPackageAvailable(packageName) {
3
+ try {
4
+ // Dynamically import the package
5
+ await import(packageName);
6
+ return true;
7
+ } catch (error) {
8
+ console.log(error);
9
+ return false;
10
+ }
11
+ }