Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to v9 #83

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "18"
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm run lint
- run: npm run test
- run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "18"
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm run lint
- run: npm run test
- run: npm run build
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ Canonical consists of 1,000+ rules (40% auto-fixable), some of which are [custom

Most projects should simply extend from [`canonical/auto`](#canonicalauto-ruleset):

```json
{
"extends": "canonical/auto"
}
```ts
// eslint.config.js
import auto from 'eslint-config-canonical/configurations/auto';

export default [
auto
];
```

## Rulesets
Expand Down
1 change: 0 additions & 1 deletion auto.js

This file was deleted.

1 change: 0 additions & 1 deletion ava.js

This file was deleted.

2 changes: 1 addition & 1 deletion bin/generate-typescript-compatibility-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ const orderedRules = {
rules: Object.fromEntries(Object.entries(appendRules).sort()),
};

// eslint-disable-next-line no-console -- CLI
// eslint-disable-next-line no-console
console.log('module.exports = ' + JSON.stringify(orderedRules, '', ' '));
1 change: 0 additions & 1 deletion browser.js

This file was deleted.

6 changes: 0 additions & 6 deletions compare/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion compare/compare.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable complexity */
/* eslint-disable no-console */
/* eslint-disable complexity */

const { writeFile, readFile } = require('node:fs/promises');
const { resolve } = require('node:path');
Expand Down
3 changes: 1 addition & 2 deletions compare/find-deprecated.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

/**
* https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/825
* https://github.com/eslint/eslint/issues/15292
Expand Down Expand Up @@ -29,6 +27,7 @@ const { getLoadedRules } = require('./utilities');
});

if (response.toLowerCase().includes('deprecated')) {
// eslint-disable-next-line no-console
console.warn(
'⚠️ ' +
ruleName +
Expand Down
4 changes: 3 additions & 1 deletion compare/utilities.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable complexity */
/* eslint-disable import/no-dynamic-require */

const { ESLint } = require('eslint');
const { builtinRules } = require('eslint/use-at-your-own-risk');

Expand Down Expand Up @@ -95,7 +98,6 @@ const getConfigurationRules = async (configuration) => {
return calculatedConfiguration.rules;
};

// eslint-disable-next-line complexity
const getRuleLink = (ruleName) => {
if (!ruleName.includes('/')) {
return (
Expand Down
59 changes: 11 additions & 48 deletions configurations/auto.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
module.exports = {
overrides: [
{
extends: [
'canonical',
'canonical/regexp',
'canonical/jsdoc',
'canonical/node',
'canonical/prettier',
],
files: ['*.js', '*.mjs', '*.cjs'],
},
{
extends: [
'canonical',
'canonical/regexp',
'canonical/jsdoc',
'canonical/node',
'canonical/typescript',
'canonical/prettier',
],
files: ['*.ts'],
},
{
extends: [
'canonical',
'canonical/regexp',
'canonical/jsdoc',
'canonical/react',
'canonical/typescript',
'canonical/prettier',
],
files: ['*.tsx'],
},
{
extends: ['canonical/json'],
files: '*.json',
},
{
extends: ['canonical/yaml'],
files: '*.yaml',
},
{
extends: ['canonical/graphql'],
files: '*.graphql',
},
],
};
module.exports = [
require('./canonical').recommended,
require('./typescript').recommended,
require('./regexp').recommended,
require('./jsdoc').recommended,
require('./react').recommended,
require('./prettier').recommended,
require('./json').recommended,
require('./yaml').recommended,
require('./graphql').recommended,
];
5 changes: 5 additions & 0 deletions configurations/auto.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const test = require('ava');

test('foo', (t) => {
t.pass();
});
11 changes: 9 additions & 2 deletions configurations/ava.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
module.exports = {
plugins: ['ava', 'unicorn'],
const ava = require('eslint-plugin-ava');
const unicorn = require('eslint-plugin-unicorn');

module.exports.recommended = {
files: ['**/*.test.{js,ts,tsx}'],
plugins: {
ava,
unicorn,
},
rules: {
'ava/assertion-arguments': 2,
'ava/hooks-order': 2,
Expand Down
14 changes: 10 additions & 4 deletions configurations/browser.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module.exports = {
env: {
browser: true,
const globals = require('globals');

module.exports.recommended = {
languageOptions: {
globals: {
...globals.browser,
},
},
plugins: {
unicorn: require('eslint-plugin-unicorn'),
},
plugins: ['unicorn'],
rules: {
'unicorn/prefer-dom-node-append': 2,
'unicorn/prefer-dom-node-dataset': 2,
Expand Down
72 changes: 42 additions & 30 deletions configurations/eslintrc.js → configurations/canonical.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@
'import/max-dependencies': 0,
'import/named': 0,
'import/namespace': 0,
'import/newline-after-import': 2,
// TODO broke after ESLint upgrade to v9

Check warning on line 24 in configurations/canonical.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected 'todo' comment: 'TODO broke after ESLint upgrade to v9'
// 'import/newline-after-import': 2,
'import/no-absolute-path': 2,
'import/no-amd': 2,
// TODO broke after ESLint upgrade to v9

Check warning on line 27 in configurations/canonical.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected 'todo' comment: 'TODO broke after ESLint upgrade to v9'
// 'import/no-amd': 2,
'import/no-anonymous-default-export': 0,
'import/no-commonjs': 0,
'import/no-cycle': 2,
'import/no-default-export': 0,
'import/no-deprecated': 1,
'import/no-duplicates': [2, { 'prefer-inline': true }],
'import/no-duplicates': [
2,
{
'prefer-inline': true,
},
],
'import/no-dynamic-require': 2,
'import/no-extraneous-dependencies': [
2,
Expand Down Expand Up @@ -194,33 +201,32 @@
'unicorn/throw-new-error': 2,
};

module.exports = {
env: {
es6: true,
},
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
plugins: ['@babel/plugin-syntax-import-assertions'],
},
ecmaFeatures: {
globalReturn: false,
impliedStrict: true,
jsx: true,
module.exports.recommended = {
languageOptions: {
parser: require('@babel/eslint-parser'),
parserOptions: {
babelOptions: {
plugins: ['@babel/plugin-syntax-import-assertions'],
},
ecmaFeatures: {
globalReturn: false,
impliedStrict: true,
jsx: true,
},
ecmaVersion: 2_021,
requireConfigFile: false,
sourceType: 'module',
},
ecmaVersion: 2_021,
requireConfigFile: false,
sourceType: 'module',
},
plugins: [
'canonical',
'@babel',
'import',
'unicorn',
'eslint-comments',
'promise',
'simple-import-sort',
],
plugins: {
'@babel': require('@babel/eslint-plugin'),
canonical: require('eslint-plugin-canonical'),
'eslint-comments': require('eslint-plugin-eslint-comments'),
import: require('eslint-plugin-import'),
promise: require('eslint-plugin-promise'),
'simple-import-sort': require('eslint-plugin-simple-import-sort'),
unicorn: require('eslint-plugin-unicorn'),
},
rules: {
...importRules,
...unicornRules,
Expand Down Expand Up @@ -664,7 +670,8 @@
'prefer-template': 0,
'promise/param-names': 2,
'promise/prefer-await-to-callbacks': 0,
'promise/prefer-await-to-then': 2,
// TODO broke after ESLint upgrade to v9

Check warning on line 673 in configurations/canonical.js

View workflow job for this annotation

GitHub Actions / Test

Unexpected 'todo' comment: 'TODO broke after ESLint upgrade to v9'
// 'promise/prefer-await-to-then': 2,
'promise/valid-params': 2,
'quote-props': [
2,
Expand All @@ -690,7 +697,12 @@
],
'semi-style': [2, 'last'],
'simple-import-sort/exports': 2,
'simple-import-sort/imports': [2, { groups: [] }],
'simple-import-sort/imports': [
2,
{
groups: [],
},
],
'sort-imports': 0,
'sort-keys': 0,
'sort-vars': 2,
Expand Down
10 changes: 6 additions & 4 deletions configurations/cypress.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module.exports = {
env: {
'cypress/globals': true,
module.exports.recommended = {
// env: {
// 'cypress/globals': true,
// },
plugins: {
cypress: require('eslint-plugin-cypress'),
},
plugins: ['cypress'],
rules: {
'cypress/assertion-before-screenshot': 2,
'cypress/no-assigning-return-values': 2,
Expand Down
6 changes: 4 additions & 2 deletions configurations/flowtype.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
plugins: ['flowtype'],
module.exports.recommended = {
plugins: {
flowtype: require('eslint-plugin-flowtype'),
},
rules: {
'flowtype/array-style-complex-type': [2, 'verbose'],
'flowtype/array-style-simple-type': [2, 'shorthand'],
Expand Down
11 changes: 8 additions & 3 deletions configurations/graphql.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module.exports = {
parser: '@graphql-eslint/eslint-plugin',
plugins: ['@graphql-eslint'],
module.exports.recommended = {
files: ['*.graphql'],
languageOptions: {
parser: require('@graphql-eslint/eslint-plugin'),
},
plugins: {
'@graphql-eslint': require('@graphql-eslint/eslint-plugin'),
},
rules: {
'@graphql-eslint/alphabetize': [
2,
Expand Down
11 changes: 6 additions & 5 deletions configurations/jest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module.exports = {
env: {
jest: true,
},
plugins: ['jest'],
module.exports.recommended = {
plugins: [
{
jest: require('eslint-plugin-jest'),
},
],
rules: {
'jest/consistent-test-it': 2,
'jest/expect-expect': 2,
Expand Down
6 changes: 4 additions & 2 deletions configurations/jsdoc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
plugins: ['jsdoc'],
module.exports.recommended = {
plugins: {
jsdoc: require('eslint-plugin-jsdoc'),
},
rules: {
'jsdoc/check-access': 2,
'jsdoc/check-alignment': 2,
Expand Down
11 changes: 8 additions & 3 deletions configurations/json.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module.exports = {
parser: 'jsonc-eslint-parser',
plugins: ['jsonc'],
module.exports.recommended = {
files: ['*.json'],
languageOptions: {
parser: require('eslint-plugin-jsonc'),
},
plugins: {
jsonc: require('eslint-plugin-jsonc'),
},
rules: {
'jsonc/array-bracket-newline': [
2,
Expand Down
Loading
Loading