Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a070824
Flatten configurations to support ESLint v9
inf1nite-lo0p Nov 19, 2024
d2ed03f
Migrate to Pnpm
inf1nite-lo0p Nov 19, 2024
b1e5b59
Install a few dev dependencies
inf1nite-lo0p Nov 19, 2024
88d0001
Setup a TSConfig file in the project's root
inf1nite-lo0p Nov 19, 2024
0df2dae
Setup test script
inf1nite-lo0p Nov 19, 2024
c38cdee
Upgrade all packages to their latest version
inf1nite-lo0p Nov 19, 2024
c25330b
Revert `test` script
inf1nite-lo0p Nov 19, 2024
457b540
5.4.6-0
inf1nite-lo0p Nov 19, 2024
acf173e
Pass env via `languageOptions.globals`
inf1nite-lo0p Nov 19, 2024
337ac60
Upgrade `peerDependency` eslint version to v9
inf1nite-lo0p Nov 19, 2024
e50f5c5
5.4.6-1
inf1nite-lo0p Nov 19, 2024
f1a6669
Convert all `require()` syntax to `import`
inf1nite-lo0p Nov 19, 2024
6cc4d0b
Add `type: "module"` to root `package.json` file
inf1nite-lo0p Nov 19, 2024
82e284f
5.4.6-2
inf1nite-lo0p Nov 19, 2024
6504369
Use default export for all rule-config utils
inf1nite-lo0p Nov 19, 2024
b34d13c
5.4.6-3
inf1nite-lo0p Nov 19, 2024
25dd087
Add `export default` to rest of eslint configs
inf1nite-lo0p Nov 19, 2024
d425192
5.4.6-4
inf1nite-lo0p Nov 19, 2024
24bd409
Use `import()` syntax for plugins as well
inf1nite-lo0p Nov 19, 2024
bef597d
5.4.6-5
inf1nite-lo0p Nov 19, 2024
2c47c67
Move `ecmaFeatures` to `parserOptions` for v9
inf1nite-lo0p Nov 19, 2024
d4bd1f6
5.4.6-6
inf1nite-lo0p Nov 19, 2024
519593c
Install v9 compatible eslint packages
inf1nite-lo0p Nov 19, 2024
7c869f9
Rework the configuration files to support the new config
inf1nite-lo0p Nov 19, 2024
0164fef
Setup a playground testing project to test config
inf1nite-lo0p Nov 19, 2024
bbf6589
5.4.6-7
inf1nite-lo0p Nov 19, 2024
bd2d71e
Fix react-hooks plugin throwing
inf1nite-lo0p Nov 19, 2024
a661a2d
5.4.6-8
inf1nite-lo0p Nov 19, 2024
cf33661
Install types for `eslint-config-prettier` package
inf1nite-lo0p Nov 19, 2024
4cb2a2d
Make prettier and styling files esm compatible
inf1nite-lo0p Nov 19, 2024
c7abe93
Include `eslintConfigPrettier` in v9 compatible way
inf1nite-lo0p Nov 19, 2024
3fb6ce9
5.4.6-9
inf1nite-lo0p Nov 19, 2024
d98f9bf
Fix the path in exports field
inf1nite-lo0p Nov 19, 2024
eaae9d9
5.4.6-10
inf1nite-lo0p Nov 19, 2024
23657ee
Add a smoke test to verify package working
inf1nite-lo0p Nov 19, 2024
000a801
Make test example apps as part of pnpm workspace
inf1nite-lo0p Nov 19, 2024
9a495bb
Deduplicate packages so that root ones are used
inf1nite-lo0p Nov 19, 2024
65cd05b
Set node and pnpm versions
inf1nite-lo0p Nov 19, 2024
af6f42c
Try treating lint failure as a success to test
inf1nite-lo0p Nov 19, 2024
bba9d59
Try `continue-on-error` option
inf1nite-lo0p Nov 19, 2024
de8f1c5
Evaluate ESLint result in a next step
inf1nite-lo0p Nov 19, 2024
6a5d291
Make eslint test pass
inf1nite-lo0p Nov 19, 2024
fbaba2a
Introduce a `should-fail` and a `should-pass` test case
inf1nite-lo0p Nov 19, 2024
e628986
Check for the var existence
inf1nite-lo0p Nov 19, 2024
63c7666
Rename `lint` to `test` in GH Action
inf1nite-lo0p Nov 19, 2024
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
70 changes: 70 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Smoke Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Setup environment
uses: prezly/setup-github-actions@v1
with:
pnpm: 9.7.0
node: 20

- name: Install dependencies
run: pnpm install

- name: Run ESLint on should-fail
id: eslint_should_fail
run: |
cd tests/should-fail
pnpm lint
lint_exit_code=$?
echo "The exit code of pnpm lint for should-fail is: $lint_exit_code"
echo "lint_exit_code=$lint_exit_code" >> $GITHUB_ENV
continue-on-error: true

- name: Evaluate ESLint result for should-fail
run: |
if [ -n "$lint_exit_code" ]; then
echo "ESLint for should-fail passed unexpectedly. Marking this as a failure."
exit 1
else
echo "ESLint for should-fail failed as expected. Marking this as a success."
exit 0
fi
env:
lint_exit_code: ${{ env.lint_exit_code }}

- name: Run ESLint on should-pass
id: eslint_should_pass
run: |
cd tests/should-pass
pnpm lint
lint_exit_code=$?
echo "The exit code of pnpm lint for should-pass is: $lint_exit_code"
echo "lint_exit_code=$lint_exit_code" >> $GITHUB_ENV
continue-on-error: true

- name: Evaluate ESLint result for should-pass
run: |
if [ "$lint_exit_code" -eq 0 ]; then
echo "ESLint for should-pass passed as expected. Marking this as a success."
exit 0
else
echo "ESLint for should-pass failed unexpectedly. Marking this as a failure."
exit 1
fi
env:
lint_exit_code: ${{ env.lint_exit_code }}
202 changes: 119 additions & 83 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,94 +1,130 @@
const importOrderConfig = require("./rule-configs/import-order/base.js");
const namingConventionConfig = require("./rule-configs/naming-convention/base.js");
//@ts-check
import importOrderConfig from "./rule-configs/import-order/base.js";
import namingConventionConfig from "./rule-configs/naming-convention/base.js";
import typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
import prettierPlugin from "eslint-plugin-prettier";
import sortExportAllPlugin from "eslint-plugin-sort-export-all";
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";

module.exports = {
env: {
browser: true,
es2021: true,
node: true,
//@ts-ignore -- Package provides no types.
import reactRefresh from "eslint-plugin-react-refresh";
//@ts-ignore -- Package provides no types.
import importPlugin from "eslint-plugin-import";

export default tseslint.config(
{
ignores: ["dist"],
},
extends: ["airbnb-base", "airbnb-typescript/base", "prettier"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx,js,jsx,mjs}"],
languageOptions: {
ecmaVersion: 2020,
parserOptions: {
projectService: true,
},
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
"react-refresh": reactRefresh,
},
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
ecmaVersion: 12,
sourceType: "module",
project: ["./tsconfig.json"],
},
plugins: [
"@typescript-eslint",
"prettier",
"import",
"sort-export-all",
"deprecation",
],
rules: {
// Prettier handles indent, whitespace and empty lines
"prettier/prettier": 2,
{
plugins: {
"@typescript-eslint": typescriptEslintPlugin,
prettier: prettierPlugin,
import: importPlugin,
"sort-export-all": sortExportAllPlugin,
},
rules: {
// Prettier rules
"prettier/prettier": 2,

// Warn about deprecated methods and properties
"deprecation/deprecation": "warn",
// Warn about deprecated methods and properties
"@typescript-eslint/no-deprecated": "warn",

// Import rules
"sort-export-all/sort-export-all": [
"error",
"asc",
{
caseSensitive: false,
natural: false,
},
],
"import/extensions": [
"error",
"never",
{ svg: "always", json: "always", css: "always", scss: "always" },
],
"import/order": ["error", importOrderConfig],
"import/prefer-default-export": "off",
"import/no-default-export": "error",
"import/no-extraneous-dependencies": "error",
"sort-imports": [
"error",
{
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
},
],
// Import rules
"sort-export-all/sort-export-all": [
"error",
"asc",
{
caseSensitive: false,
natural: false,
},
],
"import/extensions": [
"error",
"never",
{
svg: "always",
json: "always",
css: "always",
scss: "always",
},
],
"import/order": ["error", importOrderConfig],
"import/prefer-default-export": "off",
"import/no-default-export": "error",
"import/no-extraneous-dependencies": "error",
"sort-imports": [
"error",
{
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: [
"none",
"all",
"multiple",
"single",
],
},
],

// General code-style rules
"@typescript-eslint/naming-convention": namingConventionConfig,
"id-blacklist": [
2,
"arr",
"cb",
"e",
"el",
"err",
"idx",
"num",
"str",
"tmp",
"val",
],
"no-return-assign": ["error", "except-parens"],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", ignoreRestSiblings: true },
],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
// General code-style rules
// @ts-ignore
"@typescript-eslint/naming-convention": namingConventionConfig,
"id-blacklist": [
2,
"arr",
"cb",
"e",
"el",
"err",
"idx",
"num",
"str",
"tmp",
"val",
],
"no-return-assign": ["error", "except-parens"],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", ignoreRestSiblings: true },
],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",

"prefer-destructuring": "warn",
"no-nested-ternary": "warn",
"prefer-destructuring": "warn",
"no-nested-ternary": "warn",

"func-style": ["error", "declaration"],
"func-style": ["error", "declaration"],

// Extra rules
radix: "off",
radix: "off",
},
},
};
eslintConfigPrettier,
);
18 changes: 10 additions & 8 deletions lib/nextjs-tailwind.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const importOrderConfig = require("./rule-configs/import-order/next.js");
const namingConventionConfig = require("./rule-configs/naming-convention/next-tailwind.js");
import namingConventionConfig from "./rule-configs/naming-convention/next-tailwind.js";
import nextJsConfig from "./nextjs.js";

module.exports = {
extends: [require.resolve("./nextjs.js")],
rules: {
// General code-style rules
"@typescript-eslint/naming-convention": namingConventionConfig,
export default [
...nextJsConfig,
{
files: ["**/*.{ts,tsx,js,jsx}"],
rules: {
"@typescript-eslint/naming-convention": namingConventionConfig,
},
},
};
];
Loading
Loading