@jgarber/eslint-config 0.2.0 → 1.1.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/.editorconfig ADDED
@@ -0,0 +1,10 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ indent_size = 2
9
+ indent_style = space
10
+ trim_trailing_whitespace = true
@@ -0,0 +1,15 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ assignees:
9
+ - "jgarber623"
10
+ - package-ecosystem: "npm"
11
+ directory: "/"
12
+ schedule:
13
+ interval: "monthly"
14
+ assignees:
15
+ - "jgarber623"
@@ -0,0 +1,27 @@
1
+ name: CI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ lint:
7
+ name: Lint files
8
+ runs-on: ubuntu-20.04
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - uses: actions/setup-node@v3
12
+ with:
13
+ node-version-file: ".nvmrc"
14
+ cache: npm
15
+ - run: npm ci
16
+ - run: npm run lint
17
+ test:
18
+ name: Test files
19
+ runs-on: ubuntu-20.04
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - uses: actions/setup-node@v3
23
+ with:
24
+ node-version-file: ".nvmrc"
25
+ cache: npm
26
+ - run: npm ci
27
+ - run: npm test
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ lts/*
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Jason Garber
3
+ Copyright (c) 2022–present Jason Garber
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
1
  # eslint-config
2
2
 
3
- Shareable [ESLint](https://eslint.org) configurations.
3
+ Shareable [ESLint](https://eslint.org) configuration.
4
+
5
+ > **Note**
6
+ >
7
+ > As of v1.0.0, this shareable configuration uses ESLint's new "flat" configuration file format and, thus, may not be suitable for every project. See [the official documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new) for details.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm install --save-dev @jgarber/eslint-config
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Using [CommonJS module](https://nodejs.org/api/modules.html) syntax:
18
+
19
+ ```js
20
+ // eslint.config.js
21
+ module.exports = require('@jgarber/eslint-config');
22
+ ```
23
+
24
+ Using [ECMAScript module (ESM)](https://nodejs.org/api/esm.html) syntax:
25
+
26
+ ```js
27
+ // eslint.config.js
28
+ import config from '@jgarber/eslint-config';
29
+
30
+ export default [
31
+ ...config,
32
+ {
33
+ files: ['**/*.js'],
34
+ languageOptions: {
35
+ sourceType: 'module'
36
+ }
37
+ }
38
+ ];
39
+ ```
@@ -0,0 +1,15 @@
1
+ const globals = require('globals');
2
+
3
+ const config = require('./index');
4
+
5
+ module.exports = [
6
+ ...config,
7
+ {
8
+ files: ['spec/**/*[sS]pec.?(m)js'],
9
+ languageOptions: {
10
+ globals: {
11
+ ...globals.jasmine
12
+ }
13
+ }
14
+ }
15
+ ];
package/index.js CHANGED
@@ -1,22 +1,59 @@
1
- module.exports = {
2
- extends: 'eslint:recommended',
1
+ /*
2
+ * Import global identifiers from different JavaScript environments.
3
+ *
4
+ * @see {@link https://www.npmjs.com/package/globals}
5
+ * @see {@link https://github.com/sindresorhus/globals/blob/HEAD/globals.json}
6
+ */
7
+ const globals = require('globals');
3
8
 
4
- rules: {
5
- // Enforces consistent use of trailing commas in object and array literals.
6
- 'comma-dangle': ['error', 'never'],
9
+ /*
10
+ * Import Standard's ESLint configurtation for use with ESLint's new "flat"
11
+ * configuration file format.
12
+ *
13
+ * @see {@link https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json}
14
+ * @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new}
15
+ */
16
+ const standard = require('eslint-config-standard');
7
17
 
8
- // Enforces a consistent indentation style.
9
- 'indent': ['error', 2],
18
+ module.exports = [
19
+ {
20
+ plugins: Object.fromEntries(standard.plugins.map(plugin => [plugin, require(`eslint-plugin-${plugin}`)])),
21
+ rules: {
22
+ ...standard.rules,
10
23
 
11
- // Enforces consistent line endings independent of operating system, VCS,
12
- // or editor used across your codebase.
13
- 'linebreak-style': ['error', 'unix'],
24
+ /*
25
+ * Enforces consistent use of semicolons.
26
+ *
27
+ * @see {@link https://eslint.org/docs/latest/rules/semi}
28
+ */
29
+ semi: ['error', 'always'],
14
30
 
15
- // Enforces the consistent use of either backticks, double, or single
16
- // quotes.
17
- 'quotes': ['error', 'single'],
18
-
19
- // Enforces consistent use of semicolons.
20
- 'semi': ['error', 'always']
31
+ /*
32
+ * Enforces consistent spacing before function parentheses and will warn
33
+ * whenever whitespace doesn't match the preferences specified.
34
+ *
35
+ * @see {@link https://eslint.org/docs/latest/rules/space-before-function-paren}
36
+ */
37
+ 'space-before-function-paren': ['error', {
38
+ anonymous: 'never',
39
+ asyncArrow: 'always',
40
+ named: 'never'
41
+ }]
42
+ }
43
+ },
44
+ {
45
+ /*
46
+ * By default, ESLint's "flat" config considers `*.js` files as ECMAScript
47
+ * modules (ESM). Instead, consider `*.js` files to be CommonJS modules.
48
+ *
49
+ * @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects}
50
+ */
51
+ files: ['**/*.js'],
52
+ languageOptions: {
53
+ globals: {
54
+ ...globals.commonjs
55
+ },
56
+ sourceType: 'commonjs'
57
+ }
21
58
  }
22
- };
59
+ ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jgarber/eslint-config",
3
- "version": "0.2.0",
4
- "description": "Shareable ESLint configurations.",
3
+ "version": "1.1.0",
4
+ "description": "Shareable ESLint configuration.",
5
5
  "keywords": [
6
6
  "eslint",
7
7
  "eslintconfig",
@@ -12,20 +12,25 @@
12
12
  "bugs": "https://github.com/jgarber623/eslint-config/issues",
13
13
  "license": "MIT",
14
14
  "author": "Jason Garber <jason@sixtwothree.org> (https://sixtwothree.org)",
15
- "files": [
16
- "eleventy.js",
17
- "module.js"
18
- ],
19
15
  "main": "index.js",
20
16
  "repository": "github:jgarber623/eslint-config",
21
17
  "scripts": {
22
- "test": "eslint ."
18
+ "lint": "eslint .",
19
+ "test": "jasmine"
23
20
  },
24
21
  "engines": {
25
22
  "node": ">=16.0.0"
26
23
  },
24
+ "devDependencies": {
25
+ "eslint": "^8.43.0",
26
+ "eslint-config-standard": "^17.1.0",
27
+ "globals": "^13.20.0",
28
+ "jasmine": "^5.0.2"
29
+ },
27
30
  "peerDependencies": {
28
- "eslint": "^8.12.0"
31
+ "eslint": ">=8.43.0",
32
+ "eslint-config-standard": ">=17.1.0",
33
+ "globals": ">=13.20.0"
29
34
  },
30
35
  "publishConfig": {
31
36
  "access": "public"
@@ -0,0 +1,24 @@
1
+ const { FlatESLint } = require('eslint/use-at-your-own-risk');
2
+
3
+ const config = require('../index');
4
+
5
+ it('exports an Array', () => {
6
+ expect(Array.isArray(config)).toBe(true);
7
+ });
8
+
9
+ it('loads the config and validates correct syntax', async () => {
10
+ const eslint = new FlatESLint({ baseConfig: config });
11
+ const [results] = await eslint.lintText(';\n');
12
+
13
+ expect(results.errorCount).toEqual(0);
14
+ });
15
+
16
+ it('loads the config and invalidates incorrect syntax', async () => {
17
+ const eslint = new FlatESLint({ baseConfig: config });
18
+ const [results] = await eslint.lintText('(() => {}) ()\n');
19
+
20
+ const ruleIds = results.messages.map(({ ruleId }) => ruleId);
21
+
22
+ expect(results.errorCount).toEqual(2);
23
+ expect(ruleIds).toEqual(jasmine.arrayContaining(['func-call-spacing', 'semi']));
24
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "spec_dir": "spec",
3
+ "spec_files": [
4
+ "**/*[sS]pec.?(m)js"
5
+ ],
6
+ "helpers": [
7
+ "helpers/**/*.?(m)js"
8
+ ],
9
+ "env": {
10
+ "failSpecWithNoExpectations": true,
11
+ "random": true,
12
+ "stopSpecOnExpectationFailure": false
13
+ }
14
+ }
package/eleventy.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- extends: './index',
3
-
4
- env: {
5
- node: true
6
- },
7
-
8
- parserOptions: {
9
- ecmaVersion: 2017
10
- },
11
-
12
- ignorePatterns: [
13
- '!.eleventy.js',
14
- 'public/'
15
- ]
16
- };
package/module.js DELETED
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- extends: './index',
3
-
4
- env: {
5
- browser: true,
6
- es6: true
7
- },
8
-
9
- parserOptions: {
10
- sourceType: 'module'
11
- },
12
-
13
- ignorePatterns: [
14
- 'dist/*',
15
- 'spec/*'
16
- ]
17
- };