eslint-config-acme 1.0.2 → 1.3.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/README.md CHANGED
@@ -27,14 +27,17 @@ This will install the shared config, as well as its peer dependencies:
27
27
  - eslint
28
28
  - eslint-config-airbnb
29
29
  - eslint-config-prettier
30
+ - eslint-import-resolver-alias
30
31
  - eslint-plugin-import
31
32
  - eslint-plugin-jsx-a11y
32
33
  - eslint-plugin-prettier
33
34
  - eslint-plugin-react
34
35
  - eslint-plugin-react-hooks
36
+ - eslint-plugin-simple-import-sort
35
37
  - prettier
38
+ - prettier-plugin-tailwindcss
36
39
 
37
- **NOTE:** if you are on an older version of `npm` (`<7.0.0`), you will need to install these manually:
40
+ **NOTE:** if you are on NPM <7, you will need to install these manually:
38
41
 
39
42
  ```shell
40
43
  $ npx install-peerdeps -D eslint-config-acme
@@ -62,6 +65,52 @@ or the `.eslintrc` file:
62
65
  }
63
66
  ```
64
67
 
68
+ ## Import Alias
69
+
70
+ This config provides a default import alias resolver for `eslint-plugin-import` to support shorthand imports of local modules:
71
+
72
+ ```json
73
+ {
74
+ "import/resolver": {
75
+ "alias": {
76
+ "map": [["@", "./src"]],
77
+ "extensions": [".js", ".jsx"]
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ This will allow you to write imports like this anywhere in your code:
84
+
85
+ ```jsx
86
+ import Foo from '@/components/foo';
87
+ ```
88
+
89
+ instead of relative paths:
90
+
91
+ ```jsx
92
+ import Foo from '../../components/foo';
93
+ ```
94
+
95
+ when using [absolute imports and module path aliases](https://nextjs.org/docs/advanced-features/module-path-aliases) in **Next.js**.
96
+
97
+ This can also be overriden in your local `.eslintrc` file, if needed:
98
+
99
+ ```jsx
100
+ // .eslintrc
101
+ {
102
+ "extends": ["acme"],
103
+ "settings": {
104
+ "import/resolver": {
105
+ "alias": {
106
+ "map": [["@", "./lib"]],
107
+ "extensions": [".js"]
108
+ }
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
65
114
  ## Prettier
66
115
 
67
116
  This config supports Prettier integration out of the box. Rules that may conflict with ESLint are disabled via recommended configuration in [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier).
@@ -71,12 +120,12 @@ If you wish to override any [Prettier options](https://prettier.io/docs/en/optio
71
120
  ```jsx
72
121
  // .eslintrc
73
122
  {
74
- "extends": "@acme",
123
+ "extends": ["@acme"],
75
124
  "rules": {
76
125
  "prettier/prettier": [
77
126
  "error",
78
127
  {
79
- "printWidth": 110
128
+ "printWidth": 90
80
129
  }
81
130
  ]
82
131
  }
@@ -90,20 +139,22 @@ Make sure that these rules match the options specified in your `.prettierrc` fil
90
139
  Add the following to your `package.json` file to define a script that will lint all known files and output the results:
91
140
 
92
141
  ```jsx
93
- "scripts": {
94
- // ..
95
- "lint": "eslint --ignore-path .gitignore ."
96
- // ..
142
+ // package.json
143
+ {
144
+ "scripts": {
145
+ "lint": "eslint --ignore-path .gitignore ."
146
+ }
97
147
  }
98
148
  ```
99
149
 
100
150
  To fix all automatically-fixable issues, you can add the following script to your `package.json` as well (in addition to above):
101
151
 
102
152
  ```jsx
103
- "scripts": {
104
- // ..
105
- "lint:fix": "eslint --ignore-path .gitignore --fix ."
106
- // ..
153
+ // package.json
154
+ {
155
+ "scripts": {
156
+ "lint:fix": "eslint --ignore-path .gitignore --fix ."
157
+ }
107
158
  }
108
159
  ```
109
160
 
@@ -115,18 +166,16 @@ There is a [known issue](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/is
115
166
 
116
167
  Because of this, the [standard usage](https://nextjs.org/docs/api-reference/next/link) of Next.js `<Link>` component will result in an error for the `jsx-a11y/anchor-is-valid` rule. Until the Next.js API can be updated to a more standard pattern, `eslint-config-acme` overrides this rule as suggested in [this issue](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/402#issuecomment-368305051):
117
168
 
118
- ```jsx
169
+ ```json
119
170
  {
120
- // ...
121
- 'jsx-a11y/anchor-is-valid': [
122
- 'error',
171
+ "jsx-a11y/anchor-is-valid": [
172
+ "error",
123
173
  {
124
- components: ['Link'],
125
- specialLink: ['hrefLeft', 'hrefRight'],
126
- aspects: ['invalidHref', 'preferButton'],
127
- },
128
- ],
129
- // ...
174
+ "components": ["Link"],
175
+ "specialLink": ["hrefLeft", "hrefRight"],
176
+ "aspects": ["invalidHref", "preferButton"]
177
+ }
178
+ ]
130
179
  }
131
180
  ```
132
181
 
package/index.js CHANGED
@@ -18,7 +18,7 @@ module.exports = {
18
18
  jsx: true,
19
19
  },
20
20
  },
21
- plugins: ['simple-import-sort', 'import'],
21
+ plugins: ['simple-import-sort', 'import', 'tailwindcss'],
22
22
  rules: {
23
23
  ...base,
24
24
  ...next,
@@ -29,5 +29,11 @@ module.exports = {
29
29
  // Tells eslint-plugin-react to automatically detect the version of React to use
30
30
  version: 'detect',
31
31
  },
32
+ 'import/resolver': {
33
+ alias: {
34
+ map: [['@', './src']],
35
+ extensions: ['.js', '.jsx'],
36
+ },
37
+ },
32
38
  },
33
39
  };
package/lib/base.js CHANGED
@@ -33,6 +33,12 @@ module.exports = {
33
33
  },
34
34
  ],
35
35
  'simple-import-sort/exports': 'error',
36
+ 'tailwindcss/classnames-order': [
37
+ 'warn',
38
+ {
39
+ officialSorting: 'true',
40
+ },
41
+ ],
36
42
  'no-console': 'warn',
37
43
  'no-nested-ternary': 0,
38
44
  'no-underscore-dangle': 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-acme",
3
- "version": "1.0.2",
3
+ "version": "1.3.0",
4
4
  "description": "ESLint + Prettier config for React (Next.js)",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -14,16 +14,19 @@
14
14
  "lint:fix": "eslint --fix"
15
15
  },
16
16
  "peerDependencies": {
17
- "eslint": "^7.29.0",
18
- "eslint-config-airbnb": "^18.2.1",
19
- "eslint-config-prettier": "^8.3.0",
20
- "eslint-plugin-import": "^2.23.4",
21
- "eslint-plugin-jsx-a11y": "^6.4.1",
22
- "eslint-plugin-prettier": "^3.4.0",
23
- "eslint-plugin-react": "^7.24.0",
24
- "eslint-plugin-react-hooks": "^4.2.0",
17
+ "eslint": "^8.13.0",
18
+ "eslint-config-airbnb": "^19.0.4",
19
+ "eslint-config-prettier": "^8.5.0",
20
+ "eslint-import-resolver-alias": "^1.1.2",
21
+ "eslint-plugin-import": "^2.26.0",
22
+ "eslint-plugin-jsx-a11y": "^6.5.1",
23
+ "eslint-plugin-prettier": "^4.0.0",
24
+ "eslint-plugin-react": "^7.29.4",
25
+ "eslint-plugin-react-hooks": "^4.4.0",
25
26
  "eslint-plugin-simple-import-sort": "^7.0.0",
26
- "prettier": "^2.3.1"
27
+ "eslint-plugin-tailwindcss": "^3.5.0",
28
+ "prettier": "^2.6.2",
29
+ "prettier-plugin-tailwindcss": "^0.1.8"
27
30
  },
28
31
  "keywords": [
29
32
  "config",