Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Schleemann committed Mar 9, 2023
0 parents commit b2838c2
Show file tree
Hide file tree
Showing 15 changed files with 2,006 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish to NPM

on:
release:
types: [created]

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
cache: yarn
- run: yarn install
- run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# dependencies
node_modules/

# editor
.idea/
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"singleQuote": true
};
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 ATMINA Solutions GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added README.md
Binary file not shown.
46 changes: 46 additions & 0 deletions eslint/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const eslintJs = require('@eslint/js');
const importPlugin = require('eslint-plugin-import');
const globals = require('globals');

const ignores = [
'**/node_modules',
'**/build',
'**/dist',
'**/.cache',
'**/.storybook',
'**/.next',
];

/**
* @type {import('eslint').Linter.FlatConfig}
*/
module.exports = {
files: ['**/*.{ts,tsx,js,jsx}'],
ignores,
plugins: { import: importPlugin },
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
...eslintJs.configs.recommended.rules,
...importPlugin.configs.recommended.rules,
'import/order': [
'warn',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
},
};
14 changes: 14 additions & 0 deletions eslint/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { FlatCompat } = require('@eslint/eslintrc');

const compat = new FlatCompat({ baseDirectory: __dirname });

/**
* @type {import('eslint').Linter.FlatConfig}
*/
module.exports = {
...compat.extends('next'),
rules: {
// /app: The root layout actually does need a <head> element.
'@next/next/no-head-element': 'off',
},
};
33 changes: 33 additions & 0 deletions eslint/prettier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
const prettierPlugin = require('eslint-plugin-prettier');

// Turns off all rules that are unnecessary or might conflict with Prettier.
const prettierOverrides = require('eslint-config-prettier');

const prettierOptions = require('../prettier');

const ignores = [
'**/node_modules',
'**/build',
'**/dist',
'**/.cache',
'**/.storybook',
'**/.next',
];

/**
* @type {import('eslint').Linter.FlatConfig}
*/
module.exports = {
files: ['**/*.{ts,tsx,js,jsx}'],
ignores,
plugins: { prettier: prettierPlugin },
rules: {
...prettierOverrides.rules,
...prettierPlugin.configs.recommended.rules,
// Note: this effectively locks in our Prettier configuration (ignoring
// .prettierrc completely). Since this is an opinionated setup, we probably
// don't want to allow customization anyway.
'prettier/prettier': ['error', prettierOptions],
},
};
8 changes: 8 additions & 0 deletions eslint/recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @type {import('eslint').Linter.FlatConfig[]}
*/
module.exports = [
require('./base'),
require('./typescript'),
require('./prettier'),
];
8 changes: 8 additions & 0 deletions eslint/tailwind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { FlatCompat } = require('@eslint/eslintrc');

const compat = new FlatCompat({ baseDirectory: __dirname });

/**
* @type {import('eslint').Linter.FlatConfig}
*/
module.exports = compat.extends('plugin:tailwindcss/recommended');
49 changes: 49 additions & 0 deletions eslint/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const importPlugin = require('eslint-plugin-import');
const typescriptEslintPlugin = require('@typescript-eslint/eslint-plugin');
const typescriptEslintParser = require('@typescript-eslint/parser');

const ignores = [
'**/node_modules',
'**/build',
'**/dist',
'**/.cache',
'**/.storybook',
'**/.next',
];

/**
* @type {import('eslint').Linter.FlatConfig}
*/
module.exports = {
files: ['**/*.{ts,tsx}'],
ignores,
plugins: { '@typescript-eslint': typescriptEslintPlugin },
languageOptions: {
parser: typescriptEslintParser,
parserOptions: {
sourceType: 'module',
project: ['./tsconfig.json'],
},
},
settings: {
...importPlugin.configs.typescript.settings,
},
rules: {
...typescriptEslintPlugin.configs['eslint-recommended'].overrides[0].rules,
...typescriptEslintPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
'@typescript-eslint/consistent-type-exports': 'warn',
'@typescript-eslint/consistent-type-imports': [
'warn',
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': 'allow-with-description',
minimumDescriptionLength: 10,
},
],
},
};
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('Please import the configs directly from the corresponding sub-module.');
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@atmina/linting",
"version": "0.0.1",
"description": "A collection of opinionated in-house linting rules.",
"main": "index.js",
"scripts": {},
"keywords": [
"eslint",
"prettier",
"typescript"
],
"files": ["index.js", "/eslint", "/prettier"],
"author": "ATMINA Solutions GmbH <[email protected]>",
"license": "MIT",
"devDependencies": {
"@types/eslint": "^8.21.1",
"@types/node": "^18.14.6",
"@types/prettier": "^2.7.2",
"@typescript-eslint/parser": "^5.54.1",
"tailwindcss": "^3.2.7",
"typescript": "^4.9.5"
},
"dependencies": {
"@eslint/eslintrc": "^2.0.0",
"@eslint/js": "^8.35.0",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-tailwindcss": "^3.10.1",
"globals": "^13.20.0",
"prettier": "^2.8.4"
}
}
Loading

0 comments on commit b2838c2

Please sign in to comment.